CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Mon Dec 17, 2018 6:18 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Management of Unit Tests
PostPosted: Thu Mar 13, 2014 9:17 am 
Offline

Joined: Mon Mar 10, 2014 3:08 pm
Posts: 23
Hi,

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


Regards,
Malcolm


Top
   
PostPosted: Thu Mar 13, 2014 10:37 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi, Malcolm,

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


Usually, for this scenario, you have 3 projects:
  • Testee - the library which contains the POU you want to test.
  • Test Library - the library which contains the IEC unit tests (the POUs which define the test logic).
  • Testbed - a project which contains the environment where the tests are to be executed, e. G. the correct device setup, task settings etc.

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.
Attachment:
IecUnitTestInLibrary.png

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:
Code:
{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.


You do not have the required permissions to view the files attached to this post.

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Thu Mar 13, 2014 11:20 am 
Offline

Joined: Mon Mar 10, 2014 3:08 pm
Posts: 23
Hi M.Schaber,

thank you for your explanation.

Regards,
Malcolm


Top
   
PostPosted: Fri Oct 05, 2018 2:20 pm 
Offline

Joined: Thu Oct 04, 2018 10:20 am
Posts: 6
M.Schaber wrote:
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited