The test model is generated against the following specifications:
Processed elements:
The following UML elements are processed by the test model generator:
-
Java Packages
-
Java public classes
-
Java public operations.
-
Java operators are processed,
-
constructors and destructors are ignored.
-
All other elements are ignored.
Generated model
In most case is generated test element owns a «UnitTest» stereotyped Dependency
towards the tested element.
Test root
A «Test folder» stereotyped Component is created in the same package as the root Java package. This test folder will contain all generated test models.
These test models can be freely moved from this test folder. Running the "Update test" command will update the moved test model and it won’t be moved back to the test folder.
For a Java package
A Java package is generated with the same name as the tested package.
For a Java class
For each public ‘Client
’ Java class, a Java test class is generated as following:
-
It is named ‘
TestClient
’ : it has the same name as the one generated by JavaDesigner, prepended with "Test". -
It has the same name-spacing as the tested class.
-
It has
ElementImport
towards :-
‘
Client
’ so that a Java include is generated in the .java file.
-
-
It has an "import static" towards org.junit.Assert
-
The
@Before TestClient.setup()
and@After TestClient.teardown()
methods are created with an empty implementation. -
It is stereotyped with «JavaClass»
For a Java operation
For each testable doSomething(…)
operation a Java test operation is generated in the test class as following:
-
it has the
void testDoSomething()
signature, it has no parameter. -
it has a default implementation that generates a test failure, telling the test is not implemented.
-
It is annotated @Test.
-
It has the «TestOperation» stereotype