Skip to content

Anax Annotations

ixytiris edited this page Jan 8, 2020 · 29 revisions

Table of Contents

  1. @AnaxBeforeTest
  2. @AnaxTest
  3. @AnaxAfterTest
  4. @AnaxPreCondition
  5. @AnaxPostCondition
  6. @AnaxTestStep
  7. @AnaxIssues

@AnaxBeforeTest

This annotation is used to mark a method execution before the start of any test step execution including test step preconditions. Typical usage could be the cleaning of a database or the initialization of test data.

Example:

@AnaxBeforeTest
public void load(){
    log.info("First");
}

@AnaxBeforeTest(ordering = 1)
public void create(){
    log.info("Second");
}
  • ordering is used to provide the execution sequence for the before steps. The default value is 0 which means that the before steps are unordered or physically ordered as they are discovered.

@AnaxTest

This annotation is used to mark a Spring bean as a test case. A Test case is a set of test steps and their pre and post conditions in which the exit condition of the previous test step is the input condition for the current test step.

Example:

@AnaxTest(description = "myTest",value="My test suite", priority=1)
@Component
public class TestGoogle1 {
    @AnaxBeforeTest
    public void load(){

    }
    @AnaxTestStep(description = "Given then ")
    public void test_step1(){
       
    }
}
  • description is used to provide a description for the test that is reflected at the Report engine (we propose that Allure Report module is included for reporting)
  • value is used to assign the test spring bean to a test suite. All tests belonging to the same test suite will be executed sequentially based on the priority. The default value is "Anax Default Suite"
  • priority is used to specify the test execution order within a suite

@AnaxAfterTest

This annotation is used to mark a method execution after the end of all test steps executions and the test step postconditions. Typical usage could be the cleaning of a database or housekeeping tasks.

Example:

@AnaxAfterTest
public void clean(){
    log.info("Clean created data");
}

This annotation accepts no parameters

@AnaxPreCondition

This annotation is used to mark the execution of a list of methods before the execution of a specific test step.

Example:

@AnaxTestStep()
@AnaxPreCondition(methodNames = {"preCondition1","preCondition2"})
public void test_step1(){
}

public void preCondition1(){
        log.info("Class1: Runs once before test_step1");
}

public void preCondition2(){
        log.info("Class1: Runs once before test_step1 and after method preCondition1");
}
  • skip is used to skip the test step precondition execution; if skip=true, the step will not be executed.
  • methodNames is used to mark the list of methods to be executed before the execution of the current test step.

@AnaxPostCondition

This annotation is used to mark the execution of a list of methods after the execution of a specific test step. A typical usage would be to bring the app to a specific state even if the test step failed

Example:

@AnaxTestStep()
@AnaxPostCondition(methodNames = {"postCondition1","postCondition2"})
public void test_step1(){
}

public void postCondition1(){
        log.info("Class1: Runs once after test_step1");
}

public void postCondition2(){
        log.info("Class1: Runs once after test_step1 and after method postCondition1");
}
  • skip is used to skip the test step precondition execution; if skip=true, the step will not be executed.
  • methodNames is used to mark the list of methods to be executed before the execution of the current test step.

@AnaxTestStep

This annotation is used to specify a method that constitutes a step within a test execution.

Example:

@AnaxTestStep(descriptions = "testing step 6", ordering = 6, dataprovider="testGoogle1DataProvider")
public void test_step6(TestDataObj myDataObj){
   log.info("Class1: Test step6");
   System.out.println(myDataObj.name);
}
  • ordering is used to provide the execution sequence for the test steps. The default value is 0 which means that the steps are unordered or physically ordered as they are discovered.
  • description is used to provide a description for the step that is reflected at the Report engine (we propose that Allure Report module is included for reporting)
  • skip is used to skip the test step execution; if skip=true, the step will not be executed.
  • dataprovider is a Service class (Spring bean) that implements the DataProvider interface (see Data Provider
  • datasupplier is a Service class (Spring bean) that implements the DataSupplier interface (see Data Supplier

The concept of DataProvider and DataSupplier is discussed in detail in the relevant pages.

@AnaxIssues

This annotation is used to add bugs on reporting and on the tc execution at zira

Example:

    @AnaxIssues(issueNames = {"https://jira.persado.com/browse/PROJ-XXX","https://jira.persado.com/browse/PROJ-YYY"})
    @AnaxTestStep(description = "Verify")
    public void test_step1() throws Exception{
        Assert.isTrue(1==2);
    }