Skip to content

How to reuse code in repetitive Unit Tests #174

Answered by Aliazzzz
lpillsbury asked this question in Q&A
Discussion options

You must be logged in to vote

You can declare a testmethod named:

METHOD VFD_DynamicTest : BOOL
VAR_INPUT
   TestName : T_MaxString; // Test Name
   ExpValue: WORD; // Expected Value
   MyVFD : POINTER TO FB_VFD;
   FailMsg : T_MaxString; // Fail Message
END_VAR

And the code (example)

IF TEST_ORDERED( TestName ) THEN

   (* Stage this Test Here *)
   MyVFD^.Cmd( 2#0110_0000 ) ;  /// Writes Some command to the testee
   ExpValue := MyVFD^.Status();

   (* Assertion Here *)
   AssertEquals_Word( Actual := MyVfD^.GetStatus(),// Some code which provides the current object Status
                                  Exp := ExpValue, // Some code which provides the expected value
                                  Message := F…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@Aliazzzz
Comment options

@lpillsbury
Comment options

@Bulkje
Comment options

@Aliazzzz
Comment options

@Bulkje
Comment options

Answer selected by sagatowski
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants