I guess the commercial/open source options are limited. I might just start a separate PLC project that uses the TwinCAT3 projects (as libraries), and then create a test suite which instantiates the FBs, provides them with some data and asserts that the output of the FBs (either directly or by calling their methods) give what they are supposed to.
The basic setup to create an automated test framework is relatively easy. But if you have all tools together, there will got many hours into the project, and 1500€ for the codesysframework maybe cheaper (and better?). But if you do it on your own, you have the advantage that you can expand the framework for whatever you need.
My testing "test framework" does it in the way you described.
I've got a for example a testfunction which adds two integers,
and one or more test descriptions to make some tests if the function works. This is a little bit similar to googletest:
Code:
TEST(AdditionTest, BasicTest) {
VAR
retval : INT;
END_VAR
BEGIN
retval := FCADD(IN1 := 1, IN2 := 2);
EXPECT_EQ_I(IN1 := 3, IN2 := retval);
END
}
TEST(NegativeTest, BasicTest2) {
VAR
retval2 : INT;
END_VAR
BEGIN
retval2 := FCADD(IN1 := -100, IN2 := -10);
EXPECT_EQ_I(IN1 := -110, IN2 := retval2);
END
}
I've written a small python script which parses the testdiscription, and builds a function block for each testcase, and a main-function which calls them one after each other.
EXPECT_EQ_I is a test function which makes the test, and puts the result of the test into a big string array, which I readout at the end.
With my Step7 environment it takes about 30 seconds for a complete testrun. Click "start test", build test, compile, download and get the results.
It all depends if you can do all steps automated via an external interface. If it would take to many manual steps, I wouldn't use it. With Siemens TIA portal for example, you can't do this.