Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Unit Tests



The protoFramework Project provides several hundreds of Unit Tests defined using JUnit. The Netbeans ant built file allows to execute all these tests. Note that to have more information on how JUnit tests work, see JUnit concepts.

Ordering test methods

By default the execution of tests methods is not ordered. It is possible to enforce their order with a specific annotation.
      @RunWith(OrderedRunner.class)
      public class MyUnitTestClass {
      ...
      @Test
      @Order(order = 2)
      public void testMethod() {
      ...

Tests categories

Unit tests are grouped in categories. By default all tests will run, but if you want to set which categories of tests will run, you must modify the categories.properties file. By default, all Unit Tests will run, for all categories.

Code annotation

To specify a Unit Test as belonging to one or sevral categories, you have to add the following annotations before the test class declaration:
      @RunWith(CategoryRunner.class)
      @Category(cat = "archi")
      @Category(cat = "server")
      public class MyUnitTestClass {
or
      @RunWith(OrderedRunner.class)
      @Category(cat = "archi")
      @Category(cat = "server")
      public class MyUnitTestClass {

Run only one category of tests


If you want only Unit tests of a specific category to run, change the categories.properties file. For example:
      strictMode=false
      parser=true
      runtime=
      python=
      ...
In this example, only Unit Tests which are in the "parser" category will run.

Run several categories of tests

If you want only Unit tests of several specific category to run, specify more than one category in the categories.properties file. For example:
      strictMode=false
      parser=true
      runtime=true
      python=
      ...
In this example, only Unit Tests which are in the "parser" category or in the "runtime" category will run.

The strictMode allows to execute only Unit tests which belong in all the selected categories. For example:
      strictMode=true
      parser=true
      runtime=true
      python=
      ...
In this example, only Unit Tests which are in both the "parser" category and the "python" category will run.

See also


Categories: development

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence