Java EE Integration Test Framework. Integration tests run inside the application container with all the transaction management available.
- Put the following dependency in your pom.xml
<dependency>
<groupId>io.probedock</groupId>
<artifactId>jee-itf</artifactId>
<version>2.1.1</version>
</dependenc>- Create your EJB test controller
classandinterface. This controller will define the different test suites. You have to extendAbstractTestController.
@Local
public interface MyTestController extends TestController {
}
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class MyTestControllerImpl extends AbstractTestController implements MyTestController {
@EJB
public MyFirstClassTest myFirstClassTest;
// ... defines other test classes there
}- Write your first test. Each of your test suites must extends
TestGroup.
import io.probedock.jee.itf.TestGroup;
public interface MyFirstClassTest extends TestGroup {
}
----
import io.probedock.jee.itf.annotations.Test;
public class MyFirstClassTestImpl implements MyFirstClassTest {
@EJB
public MyEjbToTest myEjbToTest;
@Test
public Description myEjbToTestShouldDoAnAddition(Description description) {
int result = myEjbToTest.add(2, 2);
/**
* At the moment, the framework is limited by the fact there is no builtin assertions like Junit.
* In place, you have the full control of the description which is pass to each test or before/after methods.
* The description MUST be returned at the end of the test.
*/
if (result != 4) {
return description.fail("The result is not correct");
}
else {
return description.pass();
}
}
@Override
public TestGroup getTestGroup() {
return this;
}
}Remark: The framework takes care the transaction management for you. Each test will be run in its own transaction that
will be rolledbacked at the end of the test. You can create methods to be run before/after one/all test. The annotation is
@TestSetup and for the tests the annotation is @Test. With these two annotations, you will be able to control the behavior
of the transaction management. Running data population in/out the test transaction is possible.
- Extends
AbstractDefaultTestResourcein your web test project.
import io.probedock.jee.itf.rest.AbstractDefaultTestResource;
@Resource
public class TestEndPoint extends AbstractDefaultTestResource {
@EJB
private MyTestController myTestController;
@Override
public TestController getController() {
return myTestController;
}
}- Make sure the resource is exposed as standard REST resource. If you use annotations, you can follow the next example:
@Application
public class TestRestApplication extends Application {
}-
Deploy your application.
-
To start the tests, you need to do
POSTrequest with the following content in the body. In fact, you have the full control of the path where the resource is exposed.
{
"filters": [{
"type": "key",
"text": "agas"
}, {
"type": "tag",
"text": "feature-a"
}],
"seed": 123456
}| Name | Mandatory | Description |
|---|---|---|
| filters[] | No | Define a list of filters to run specific tests. |
| seed | No | Used to generate the test run order. If not sent, the order is random and the seed will appear in the logs. |
| Name | Mandatory | Description |
|---|---|---|
| type | Yes | The filter type: *, key, name, fingerprint, tag and ticket are valid values. |
| text | Yes | Free text applied to filter type to match tests to run. |
- Java 6+
- Fork
- Create a topic branch -
git checkout -b feature - Push to your branch -
git push origin feature - Create a pull request from your branch
Please add a changelog entry with your name for new features and bug fixes.
jee-itf is licensed under the MIT License. See LICENSE.txt for the full text.