|
|
When contributing to alya, you'll have to add tests to ensure that the features you added or modified do not impact negatively the code behavior. The code coverage helps the developer to detect if the code he has added is already covered by the testsuite. If it is not the case, you are invited to add a new test to cover your contributions.
|
|
|
When contributing to alya, you'll have to add tests to ensure that the features you added or modified do not impact negatively the code behavior. For specific functionalities unity tests are an appropriate option. By running the command "make test" all the unity tests will be executed. Note that unity tests should not be expensive in terms of computing or memory resources.
|
|
|
|
|
|
## Alya tests structure
|
|
|
## Alya unity tests structure
|
|
|
|
|
|
Tests are located in `alya/tests` directory. You will find several subdirectories, organized by modules (kernel, nastin,...) or by features (mpio)
|
|
|
To add a new test, choose the appropriate subdirectory, or create a new one.
|
|
|
|
|
|
Let's say you want to add a new test for nastin:
|
|
|
|
|
|
`cd tests/nastin`
|
|
|
Tests are located in `alya/unitt` directory. You will find several subdirectories containing different unity tests.
|
|
|
To add a new test, just create a new subdirectory with the name "unitt_XX", where XX are some words describing your tests separated by the character "_" (see existing examples).
|
|
|
|
|
|
## Create the new test
|
|
|
|
|
|
Create a new directory for your test. We will name this test `test-example`
|
|
|
Create a new directory for your test. We will name this test `unitt_test_name`
|
|
|
|
|
|
`mkdir test-example`
|
|
|
`mkdir unitt_test_name`
|
|
|
|
|
|
You will take care of keeping the same name for the test directory and the files contained within.
|
|
|
|
|
|
## Add .dat files
|
|
|
Add the file with the code for your unity test. You will take care of keeping the same name for the test directory and the files contained within (as in the existing examples).
|
|
|
|
|
|
In the `test-example`, add the required .dat files to run your test. Their name must follow the test directory name:
|
|
|
In this folder add also the file "CMakeLists.txt" that you can find within the other's unity tests folder, without changing any thing from this file.
|
|
|
|
|
|
- `test-example.dat`
|
|
|
- `test-example.dom.dat`
|
|
|
- `test-example.ker.dat`
|
|
|
- `test-example.nsi.dat`
|
|
|
- etc.
|
|
|
In the root folder that contains all the tests, edit the file "CMakeLists.txt" add your subdirectory:
|
|
|
|
|
|
## Add .json file.
|
|
|
add_subdirectory(unitt_test_name)
|
|
|
|
|
|
Add a new `test-example.json` that configures the test. The file format is described [here](./Test-configuration)
|
|
|
|
|
|
## Reference files
|
|
|
|
|
|
Create the `base/1p` directory to store the reference files used to validate the execution results.
|
|
|
## Add and commit the files
|
|
|
|
|
|
`mkdir -p base/1p`
|
|
|
Add and commit the files that are required to run your test. Do not commit to the test directory any file that is generated during the execution nor any file that is not necessary to run the test.
|
|
|
|
|
|
Put inside the files you will compare after the case execution. Take care of merging the subdomains. These files must have exactly the same name as those generated during alya execution.
|
|
|
## Run the unity test
|
|
|
|
|
|
## Add and commit the files
|
|
|
In your build directory, run the command:
|
|
|
|
|
|
Add and commit the files that are required to run your test. Do not commit to the test directory any file that is generated during the execution nor any file that is not necessary to run the test. |
|
|
make test |