The test model is generated against the following specifications:
Processed elements:
The following UML elements are processed by the test model generator:
-
Cxx Packages
-
Cxx public classes
-
Cxx public operations.
-
Cxx 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 package is created in the same package as the root Cxx 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 Cxx package
A Cxx package is generated with the same name as the tested package.
For a Cxx class
For each public ‘Client
’ C class, a C test class is generated as following:
-
It is named ‘
TestClient
’ : it has the same name as the one generated by CxxDesigner, prepended with "Test". -
It has the same name-spacing as the tested class.
-
It has an
ElementImport
towards ‘Client
’ so that a Cxx include is generated in the .cxx file. -
It is set as friend of the tested class by creating a
[friend]
Usage
from the tested class to the test class.If the tested class is read only, the link will not be created and a warning will be reported at the end of the generation.
-
It inherits from
CppUnit::TestFixture
-
It declares a
TestClient
test suite in the class declaration using theCPPUNIT_TEST_SUITE(TestClient)
and other helper macros. -
The
TestClient::setup()
andTestClient::teardown()
methods are created with an empty implementation. -
If activated in the module parameters, the test suite is registered in the default test suite registry using the CPPUNIT_TEST_SUITE_REGISTRATION macro.
-
It is stereotyped with
[CppUnit]
For a Cxx operation
For each testable doSomething(…)
operation a Cxx 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 registered as a
TestCaller
in the generatedstatic CppUnit::TestSuite * TestClass::suite()
method. -
It has the «TestOperation» stereotype
For a Cxx operator :
A test operation is generated the same way as for Cxx methods, excepted the test method name which the concatenation of "`test_operator`"_ followed by the english name of the operator.
eg : for a :
1
C1& C1::operator =(const C1& value)
operator, the generated test method is :
1
void TestC1::test_operator_assign()