Analysis of the technical principles of ALLure Java Annotations framework in the Java Library

Analysis of the technical principles of ALLure Java Annotations framework in the Java Library introduction: Allure Java Annotations is a Java class library for writing test cases. It provides a simple way to add additional information and annotations to test cases.This article will analyze the technical principles of the ALLURE JAVA Annotations framework and provide some Java code examples. Introduction to allure Allure is a lightweight open source test report framework, which provides a rich HTML test report and a powerful test results visualization function.Allure uses an annotation method to collect test results and build test reports. Second, the use of Allure Java Annotations framework The Allure Java Annotations framework provides a series of annotations to describe the information of the test case, including the priority, severity, description, steps of the test case.Here are some commonly used annotation examples: 1. @Descripting -to describe the function or purpose of the test case. @Test @Descripting ("This is an example test case") public void exampleTestCase() { // The specific implementation of the test case } 2. @Severity -The severity level for specifying test cases. @Test @Severity(SeverityLevel.CRITICAL) public void criticalTestCase() { // The specific implementation of the test case } 3. @step -Steps used to mark test cases. @Test public void testSteps() { step1(); step2(); step3(); } @Stetep ("Executive Step 1") public void step1() { // Execute the code of step 1 } @Stetep ("Executive Step 2") public void step2() { // Execute the code of Step 2 } @Stetep ("Executive Step 3") public void step3() { // Execute the code of step 3 } The above is only a part of the commonly used annotations in the Allure Java Annotations framework. You can choose the appropriate annotation to describe your test case as needed. Third, the technical principles of allure java annotations The technical principles of the Allure Java Annotations framework mainly involve two aspects: runtime annotations and test results collection. 1. Run the annotation processing The Allure Java Annotations framework achieves the processing of testing the test case by using the expansion function of the test framework such as Junit or Testng.Before running the test case, allure analyzes the annotations in the test class and the test method, and saves the information of these annotations into the ALLURE context. 2. Test results collection When the test case is executed, allure will extract the annotation information of the test case from the ALLURE context and transform these information into the Allure test results model.Allure then stores these test results models into a temporary directory. In order to generate a test report from the test result model, Allure also needs to run a Allure command line tool after the test is completed.The tool reads the results model in the temporary directory and converts them into a test report in HTML format. Four, somed This article analyzes the technical principles of the ALLURE JAVA Annotations framework and provides some commonly used annotations.By using Allure Java Annotations framework, testers can more easily describe and collect information about test cases and generate beautiful and visual test reports. Reference link: -Allure official website: https://github.com/allure-framework/allure2