This library provides rich metadata to JUnit4 tests and consists of two main parts:
- Test metadata annotations
- Test categories for test classification
These parts are explained below in detail.
Maven:
<dependency>
<groupId>cz.auderis</groupId>
<artifactId>auderis-test-category</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
Gradle:
dependencies {
compileTest: 'cz.auderis:auderis-test-category:1.1.0'
}
Often a release version of a software product is characterized by a list of issues (bugs, feature requests etc.) that
were resolved since the last release. These issues are typically registered in a issue tracking system and in most
cases, they are assigned unique IDs (for example, JIRA-739
).
In order to automatically validate the correctness of a release candidate, we need to make sure that each issue is processed and its result (a bug fix or new code) is testable. Considering the normal workflow (an issue is opened and assigned to a developer, who then resolves it), we feel that the most convenient place to define the issue-test relation is through the use of Java annotation at the test source level.
Example:
public class NumericTest {
@Test
@VerifiesIssue( 'JIRA-739' )
public void shouldPreventOverflowWhenValueIsLarge() throws Exception {
// ...
}
}
JUnit framework introduced a concept of test categorization which can be easily exploited by build tools and/or test runners. Categories are expressed in terms of Java classes (allowing inheritance relationships between categories). This library provides a rich set of generic, often needed categories, where the ones with the widest scope being:
UnitTest
for basic unit testingAcceptanceTest
- important QA tests that correspond with software requirementsSanityTest
- tests that verify the build environmentSmokeTest
- tests designed to reveal simple but severe defects
RegressionTest
- tests that check for bugs introduced by code changes during QA phasePerformanceTest
- tests that verify performance aspects of code
Among other provided categories are those that declare certain properties of a test, such as its relationship to a certain subsystem, its expected performance or test maturity:
IntegrationTest
- for tests that verify multi-component interactionsDatabaseTest
- tests of interactions between code and databasesNetworkTest
- tests oriented at network communications
UserInterfaceTest
- tests targeted at user interfaceSecurityTest
- tests that validate security propertiesSlowTest
- tests that can run for a significant timeVerySlowTest
- tests that can run for a very long time
DetailedTest
- tests of inner code behaviour that are not necessary for normal test runsUnstableTest
- incomplete or misbehaving tests
For tests that target a specific OS platform, the following tests are available:
PlatformTest
- tests that check platform dependent aspectsLinuxPlatformTest
- tests targeting LinuxWindowsPlatformTest
- tests targeting WindowsOSXPlatformTest
- tests targeting OSXAndroidPlatformTest
- tests targeting Android
(Notice that generic PlatformTest
category may be useful for global exclusion of platform-specific
tests from a test run.)
For more information, consult JavaDoc of individual categories (in package cz.auderis.test.category
).
JUnit tests can be tagged either on method level, or globally on test class level.
In the following example, test method shouldConnectToDatabase
has 3 categories
assigned: UnstableTest
(from class annotation), DatabaseTest
(from method
annotation) and IntegrationTest
(implicit ancestor of the database test category).
@Category( UnstableTest.class )
public class SomeTests {
@Test
@Category( DatabaseTest.class )
public void shouldConnectToDatabase() throws Exception {
// ...
}
}
The library is licensed under the Apache License, Version 2.0.
In short, the software is distributed "as is", without any warranties. Please consult
included file LICENSE
for details.
-
1.1.0
- Categories for platform-oriented tests added
-
1.0.1
- Documentation expanded
-
1.0.0
- Initial public release