Skip to content

Unit Tests

Philipp edited this page Apr 3, 2020 · 14 revisions

To test new functionalities and refactorings of the Neural-Network-Translator, some unit tests have been implemented.

Execution of all available Unit Tests

To execute all available unit tests for this project, the following command can be executed (from the root directory of the repository):
python -m test.complete_test_suite

This module will call all test cases from all available unit test suites.

Naming Convention for Unit Tests

The names of all unit tests are oriented to the following naming scheme:
[test_MethodName_StateUnderTest_ExpectedBehavior]

This should facilitate the interpretation of the unit test methods by their name.

Components with currently available Unit Tests

Unit Tests for the GCC Backend Plugin

The unit tests for the GCC backend include one test at the moment.

Examplary unit tests:

  • test_buildMarkers_validIntermediateFormat_validMarkerDict

This tests can also be executed seperately with the following command (executed from the root directory of the repository):
python -m test.gcc_backend_test

Unit Tests for the backend_utils

The unit tests for the backend_utils class include 26 tests at the moment.

Examplary unit tests:

  • test_replaceMarkers_stringWithSingleMarker_correctReplacedMarker
  • test_replaceMarkers_stringWithNotExistentMarker_noReplacementDone
  • test_convertArrayToString_onlyIntegerValues_correctStringRepresenationOfIntegerValues
  • test_getNumberOfLayers_3DenseLayerInput_correctNumberOfLayers
  • test_getLayerTypesString_2DenseLayerInput_correctLayerTypesString
  • test_getOutputDimensions_poolingLayerInput_correctHeightWidthDepthDimensions
  • test_getWeightInformation_MixedLayerSomeUsingWeightsTrueInput_correctWeightsValueStringWeightsIndicesString

This tests can also be executed separately with the following command (executed from the root directory of the repository):
python -m test.backend_utils_test