Management of Unit Tests

Malcolm
2014-03-13
2018-10-05
  • Malcolm

    Malcolm - 2014-03-13

    Hi,

    how can I source out unit tests in a test library?

    Regards,
    Malcolm

     
  • Anonymous - 2014-03-13

    Originally created by: M.Schaber

    Hi, Malcolm,

    Malcolm hat geschrieben:
    how can I source out unit tests in a test library?

    Usually, for this scenario, you have 3 projects:

    The "test library" needs to reference the "testee" library, and then the "testbed" project references the "test library".

    I did attach a screenshot where you can see a testbed project which defines some of their own unit tests, as well as it references the CodeGeneratorTest library (newest version), and then the IEC Unit Test configuration which executes the unit tests from both the testbed project and the test library.

    For smaller projects and libraries, you don't need to source the unit tests out into their own test library - the compiler only compiles and downloads code which is actually referenced from the application, so as long as as you don't explicitly reference (create instances of and call) the test POUs within the application code, they are not part of the normal download, and thus can stay within the project or library without doing any harm.

    Some Developers like to keep tests and code together, so they have all their unit test POUs within the library which defines the testees. If they want to lower user confusion, they can add hide their test POUs using: ```

    {attribute 'hide'}

    ``` - see the online help chapter "Programming Reference > Declaration > Pragma Instructions > Attribute Pragmas > Attribute hide" for more information.

    In some cases, you have the same testee and test library, but several different testbed projects - e. G. for our compiler tests, we have one testbed project for each target platform.

    IMG: IecUnitTestInLibrary.png

     
  • Malcolm

    Malcolm - 2014-03-13

    Hi M.Schaber,

    thank you for your explanation.

    Regards,
    Malcolm

     
  • kai-sew

    kai-sew - 2018-10-05

    M.Schaber hat geschrieben:
    Some Developers like to keep tests and code together, so they have all their unit test POUs within the library which defines the testees.

    Hello M.Schaber,

    do you have any suggestion about managing other test files, namely the test scripts and the project files of testbeds?

    These files should also be checked into version control system and shared with other developers.

    Best Regards
    Kai

     

Log in to post a comment.