Defining PRG_TEST task to run my unit tests #173
-
Hi everyone, I just wrote my first PLC program and now I want it to have unit tests (I know, I know I should have done it the other way around-- but I didn't know about TcUnit when I started). Anyways, I'm ok with the TcUnit syntax and setup--except how do I run my tests? I already have a MAIN, and when I Activate Configuration/Build that's what runs. I've followed the tcunit.org documentation and @sagatowski's videos pretty carefully (thank you for this) and my best guess is the line in the intro user's guide that says "we need to have a program PRG_TEST defined in a task that we can run locally on our engineering PC". I see only MAIN in my PlcTask in the Solution Explorer and I don't know how to get PRG_TEST there also (if that's what I need). Below is a screen shot of my Solution Explorer--all the tests are grayed out for probably the same reason. What am I missing? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi Leah! The PRG_TEST is just a program just like any other where you instantiate all your test suites. It doesn't have to be named PRG_TEST, you can name it whatever you want (it was just a suggestion). For the tests to execute however, the PRG_TEST (or whatever program you have your tests declared in) need to be linked to a task. There are two ways to go about this:
I hope I was clear with my description. If you have any further questions, please ask. ps. |
Beta Was this translation helpful? Give feedback.
-
I just realized that this is not 100% clear in the current documentation. I will add an entry to the F.A.Q. of TcUnit before the end of the week. |
Beta Was this translation helpful? Give feedback.
Hi Leah!
The PRG_TEST is just a program just like any other where you instantiate all your test suites. It doesn't have to be named PRG_TEST, you can name it whatever you want (it was just a suggestion). For the tests to execute however, the PRG_TEST (or whatever program you have your tests declared in) need to be linked to a task.
There are two ways to go about this:
Split the project into a library project + executable project. You can either create a separate library project that only includes all your function blocks and all your tests, and then create a library out of this that is used in the main executable project. The library will then only have one program for the unit tests (P…