AludraTest supports definition of concurrency characteristic on every test run node by annotation.
Test run nodes are:
Annotations for concurrency characteristic are:
@org.aludratest.testcase.Parallel
defines parallel execution@org.aludratest.testcase.Sequential
defines sequential executionThis gives the freedom, to execute e.g. health check or smoke test suites first and afterwards all other tests. It also allows to define an explicit sequence of name tests, if necessary.
AludraTest will use the parse the test execution tree and use the most narrow definition of execution order:
A test method may be parameterized with test data and data source. AludraTest will call the test method for each data set the data source provides exactly one time. If there are ten data sets, the method is called ten times with the ten unique data sets.
By adding the annotation @Parallel
to the method's definition, AldraTest will run the ten combinations of method and data set parallel.
Example:
import org.aludratest.testcase.AludraTestCase; import org.aludratest.testcase.Parallel; import org.aludratest.testcase.Sewuential; import org.aludratest.testcase.data.Source; import org.aludratest.testcase.Test; public class MyTestClass extends AludraTestCase { // this test derives concurrency from class and test suite hierarchy @Test @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void derivedTest(TestData data) { logInfo("test data: " + data); } // this test runs parallel @Test @Parallel @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void parallelTest(TestData data) { logInfo("test data: " + data); } // this test runs sequential @Test @Sequential @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void sequentialTest(TestData data) { logInfo("test data: " + data); } }
Test classes can be annotated with concurrency characteristics. This will be applied:
The following parallel class will try to assign the runs to all three test methods parallel. Additionally the method derivedTest()
will run it's data sets parallel. According available threads, all three will start parallel, but sequntialTest()
will finish last, as their data sets are executed sequentially.
import org.aludratest.testcase.AludraTestCase; import org.aludratest.testcase.Parallel; import org.aludratest.testcase.Sewuential; import org.aludratest.testcase.data.Source; import org.aludratest.testcase.Test; @Parallel public class ParallelClass extends AludraTestCase { @Test @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''derivedTest'''(TestData data) { logInfo("test data: " + data); } @Test @Parallel @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''parallelTest'''(TestData data) { logInfo("test data: " + data); } @Test @Sequential @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''sequentialTest'''(TestData data) { logInfo("test data: " + data); } }
The SequntialClass{}
will run the test methods in fixed sequence:
derivedTest()
sequentially, thenparallelTest()
parallel, as force by method annotation. ThensequentialTest()
sequentiallyimport org.aludratest.testcase.AludraTestCase; import org.aludratest.testcase.Parallel; import org.aludratest.testcase.Sewuential; import org.aludratest.testcase.data.Source; import org.aludratest.testcase.Test; @Sequential public class SequentialClass extends AludraTestCase { @Test @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''derivedTest'''(TestData data) { logInfo("test data: " + data); } @Test @Parallel @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''parallelTest'''(TestData data) { logInfo("test data: " + data); } @Test @Sequential @Source(uri="ExcelFileWith10Lines.xls", segment="sheet1") public void '''sequentialTest'''(TestData data) { logInfo("test data: " + data); } }
Test Suites annotated with @Parallel
or @Sequential
behave the same like classes, but apply the mechanism to test classes and test suites.
import org.aludratest.Suite; @Parallel @Suite({ MyTestClass1.class, MyTestClass2.class, NestedTestSuite.class }) public class MyTestSuite {}