From c7c856302f6ada9675c6a8e8e84b95d0a0ac8f36 Mon Sep 17 00:00:00 2001 From: Stefan Besler Date: Sat, 18 Nov 2023 17:40:24 +0100 Subject: [PATCH] feat(xUnitXmlPublisher): Include assertion message in test output --- TcUnit/TcUnit/DUTs/ST_TestCaseResult.TcDUT | 1 + .../TcUnit/ITFs/I_AssertMessageFormatter.TcIO | 2 +- .../POUs/FB_AdsAssertMessageFormatter.TcPOU | 7 +- TcUnit/TcUnit/POUs/FB_Test.TcPOU | 19 + TcUnit/TcUnit/POUs/FB_TestResults.TcPOU | 4 + TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU | 471 +++++++++++++----- TcUnit/TcUnit/POUs/FB_xUnitXmlPublisher.TcPOU | 24 +- TcUnit/TcUnit/TcUnit.plcproj | 2 +- TcUnit/TcUnit/Version/Global_Version.TcGVL | 2 +- 9 files changed, 396 insertions(+), 136 deletions(-) diff --git a/TcUnit/TcUnit/DUTs/ST_TestCaseResult.TcDUT b/TcUnit/TcUnit/DUTs/ST_TestCaseResult.TcDUT index 2d77c16..d0c58e2 100644 --- a/TcUnit/TcUnit/DUTs/ST_TestCaseResult.TcDUT +++ b/TcUnit/TcUnit/DUTs/ST_TestCaseResult.TcDUT @@ -8,6 +8,7 @@ STRUCT TestIsFailed : BOOL; TestIsSkipped : BOOL; FailureMessage : T_MaxString; + FailureAssertion : Tc2_System.T_MaxString; FailureType : E_AssertionType; NumberOfAsserts : UINT; Duration : LREAL; // in seconds diff --git a/TcUnit/TcUnit/ITFs/I_AssertMessageFormatter.TcIO b/TcUnit/TcUnit/ITFs/I_AssertMessageFormatter.TcIO index 67bfe3e..59cae67 100644 --- a/TcUnit/TcUnit/ITFs/I_AssertMessageFormatter.TcIO +++ b/TcUnit/TcUnit/ITFs/I_AssertMessageFormatter.TcIO @@ -4,7 +4,7 @@ - - 0 THEN TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', EXP: '); TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Expected); + LogAssertFailure := Tc2_Standard.CONCAT('EXP: ', Expected); END_IF IF LEN(STR := Actual) > 0 THEN TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', ACT: '); TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := Actual); + LogAssertFailure := Tc2_Standard.CONCAT(LogAssertFailure, ', ACT: '); + LogAssertFailure := Tc2_Standard.CONCAT(LogAssertFailure, Actual); END_IF IF LEN(STR := Message) > 0 THEN TestInstancePathFinal := CONCAT(STR1 := TestInstancePathFinal, STR2 := ', MSG: %s'); diff --git a/TcUnit/TcUnit/POUs/FB_Test.TcPOU b/TcUnit/TcUnit/POUs/FB_Test.TcPOU index bffa9f3..b7efc23 100644 --- a/TcUnit/TcUnit/POUs/FB_Test.TcPOU +++ b/TcUnit/TcUnit/POUs/FB_Test.TcPOU @@ -19,6 +19,7 @@ VAR (* Failure parameters. If TestIsFailed is TRUE, the other parameters will hold values as well *) TestIsFailed : BOOL; // Indication of whether this test has at least one failed assert AssertionMessage : T_MaxString; // Assertion message for the first assertion in this test + AssertionFailure : Tc2_System.T_MaxString; // Assertion failure for the first assertion in this test AssertionType : E_AssertionType; // Assertion type for the first assertion in this test StartedAt : LWORD; // Temporary variable to calculate the actual duration of the test, the value holds the cpu cycle counter when a test is started in 100ns precision @@ -27,6 +28,12 @@ END_VAR]]> + + + + + + @@ -82,6 +89,18 @@ METHOD INTERNAL GetTestOrder : UINT(0..GVL_Param_TcUnit.MaxNumberOfTestsForEachT + + + + + + AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -330,10 +331,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := LREAL_TO_STRING(Actual)); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -369,6 +374,8 @@ VAR ActualArrayIndex : ARRAY[1..2] OF DINT; // Array of current Actual array indexes when looping through arrays Expected : REAL; // Single expected value Actual : REAL; // Single actual value + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_REAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -483,11 +489,15 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := '] = '); ActualString := CONCAT(STR1 := ActualString, STR2 := REAL_TO_STRING(Actual)); END_IF - - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -523,6 +533,8 @@ VAR ActualArrayIndex : ARRAY[1..3] OF DINT; // Array of current Actual array indexes when looping through arrays Expected : LREAL; // Single expected value Actual : LREAL; // Single actual value + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array3D_LREAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -665,10 +676,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := LREAL_TO_STRING(Actual)); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -707,6 +722,8 @@ VAR ExpectedValueString : T_MaxString; ActualValueString : T_MaxString; FormatString : FB_FormatString; // String formatter for output messages + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array3D_REAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -849,10 +865,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := REAL_TO_STRING(Actual)); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -880,6 +900,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_BOOL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -939,10 +960,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := BOOL_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -972,6 +997,8 @@ VAR ActualByteString : STRING; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_BYTE, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1040,10 +1066,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := ActualByteString); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1071,6 +1101,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_DINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1130,10 +1161,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := DINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1163,6 +1198,8 @@ VAR ActualDWordString : STRING; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_DWORD, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1230,10 +1266,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := ActualDWordString); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1261,6 +1301,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_INT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1320,10 +1361,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := INT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1351,6 +1396,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_LINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1410,10 +1456,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := LINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1442,6 +1492,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_LREAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1501,10 +1552,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := LREAL_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1534,6 +1589,8 @@ VAR ActualLWordString : STRING; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_LWORD, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1601,10 +1657,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := ActualLWordString); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1633,6 +1693,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_REAL, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1692,10 +1753,13 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := REAL_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1723,6 +1787,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_SINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1782,10 +1847,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := SINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1813,6 +1882,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_UDINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1869,14 +1939,17 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := 'ARRAY['; ActualString := CONCAT(STR1 := ActualString, STR2 := DINT_TO_STRING(ActualsIndex)); ActualString := CONCAT(STR1 := ActualString, STR2 := '] = '); - ActualString := -CONCAT(STR1 := ActualString, STR2 := UDINT_TO_STRING(Actuals[ActualsIndex])); + ActualString := CONCAT(STR1 := ActualString, STR2 := UDINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1904,6 +1977,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_UINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -1963,10 +2037,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := UINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -1994,6 +2072,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_ULINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -2053,10 +2132,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := ULINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2084,6 +2167,8 @@ VAR SizeOfActuals : DINT; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_USINT, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -2143,10 +2227,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := USINT_TO_STRING(Actuals[ActualsIndex])); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2176,6 +2264,8 @@ VAR ActualDWordString : STRING; ExpectedsIndex : DINT; ActualsIndex : DINT; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND NOT Equals THEN - SetTestFailed(AssertionType := E_AssertionType.Type_Array_WORD, - AssertionMessage := Message); + TestMessage := Message; IF NOT SizeEquals THEN Message := CONCAT(STR1 := Message, STR2 := ', size of arrays not matching.'); @@ -2243,10 +2332,14 @@ IF NOT AlreadyReported AND NOT Equals THEN ActualString := CONCAT(STR1 := ActualString, STR2 := ActualDWordString); END_IF - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedString, Actual := ActualString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2319,6 +2412,9 @@ VAR DataSizeNotEquals : BOOL; // The data size of the two ANY input parameters are not equal DataContentNotEquals : BOOL; // The data content of the two ANY input parameters are not equal IteratorCounter : DINT; + + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND (DataTypesNotEquals OR DataSizeNotEquals OR DataContentNotEquals) THEN - SetTestFailed(AssertionType := E_AssertionType.Type_ANY, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := ExpectedDataString, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ExpectedDataString, Actual := ActualDataString, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2630,6 +2729,8 @@ END_VAR VAR AlreadyReported : BOOL; TestInstancePath : T_MaxString; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_BOOL, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := BOOL_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := BOOL_TO_STRING(Expected), Actual := BOOL_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2672,6 +2776,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_BYTE, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := CONCAT( + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := Tc2_Standard.CONCAT( STR1 := '0x', STR2 := BYTE_TO_HEXSTR(in := Expected, iPrecision := 2, @@ -2706,6 +2811,10 @@ IF NOT AlreadyReported AND Expected <> Actual THEN bLoCase := FALSE)), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2722,6 +2831,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_DATE, - AssertionMessage := Message); - - AssertMessageFormatter.LogAssertFailure(Expected := DATE_TO_STRING(Expected), + TestMessage := Message; + + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := DATE_TO_STRING(Expected), Actual := DATE_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2764,6 +2878,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_DATE_AND_TIME, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := DT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := DT_TO_STRING(Expected), Actual := DT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2806,6 +2925,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_DINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := DINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := DINT_TO_STRING(Expected), Actual := DINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2848,6 +2972,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_DWORD, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := CONCAT( + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := Tc2_Standard.CONCAT( STR1 := '0x', STR2 := DWORD_TO_HEXSTR(in := Expected, iPrecision := 8, @@ -2882,6 +3007,10 @@ IF NOT AlreadyReported AND Expected <> Actual THEN bLoCase := FALSE)), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2898,6 +3027,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_INT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := INT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := INT_TO_STRING(Expected), Actual := INT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2940,6 +3074,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_LINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := LINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := LINT_TO_STRING(Expected), Actual := LINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -2983,6 +3122,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND ABS(Expected - Actual) > Delta THEN - SetTestFailed(AssertionType := E_AssertionType.Type_LREAL, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := LREAL_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := LREAL_TO_STRING(Expected), Actual := LREAL_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3025,6 +3169,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_LTIME, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := LTIME_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := LTIME_TO_STRING(Expected), Actual := LTIME_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3067,6 +3216,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_LWORD, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := CONCAT( + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := Tc2_Standard.CONCAT( STR1 := '0x', STR2 := LWORD_TO_HEXSTR(in := Expected, iPrecision := 16, @@ -3101,6 +3251,10 @@ IF NOT AlreadyReported AND Expected <> Actual THEN bLoCase := FALSE)), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3118,6 +3272,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND ABS(Expected - Actual) > Delta THEN - SetTestFailed(AssertionType := E_AssertionType.Type_REAL, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := REAL_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := REAL_TO_STRING(Expected), Actual := REAL_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3160,6 +3319,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_SINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := SINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := SINT_TO_STRING(Expected), Actual := SINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3202,6 +3366,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND (LEN(STR := Expected) <> LEN(STR := Actual) OR (Expected <> Actual)) THEN - SetTestFailed(AssertionType := E_AssertionType.Type_STRING, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := Expected, + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := Expected, Actual := Actual, Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3244,6 +3413,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_TIME, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := TIME_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := TIME_TO_STRING(Expected), Actual := TIME_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3286,6 +3460,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_TIME_OF_DAY, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := TOD_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := TOD_TO_STRING(Expected), Actual := TOD_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3328,6 +3507,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_UDINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := UDINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := UDINT_TO_STRING(Expected), Actual := UDINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3370,6 +3554,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_UINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := UINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := UINT_TO_STRING(Expected), Actual := UINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3412,6 +3601,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_ULINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := ULINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := ULINT_TO_STRING(Expected), Actual := ULINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3454,6 +3648,8 @@ END_VAR VAR AlreadyReported : BOOL; TestInstancePath : T_MaxString; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_USINT, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := USINT_TO_STRING(Expected), + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := USINT_TO_STRING(Expected), Actual := USINT_TO_STRING(Actual), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3496,6 +3695,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND Expected <> Actual THEN - SetTestFailed(AssertionType := E_AssertionType.Type_WORD, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := CONCAT( + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := Tc2_Standard.CONCAT( STR1 := '0x', STR2 := WORD_TO_HEXSTR(in := Expected, iPrecision := 4, @@ -3530,6 +3730,10 @@ IF NOT AlreadyReported AND Expected <> Actual THEN bLoCase := FALSE)), Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3546,6 +3750,8 @@ END_VAR VAR TestInstancePath : T_MaxString; AlreadyReported : BOOL; + TestMessage : Tc2_System.T_MaxString; // Holds the actual message of the test + TestFailure : Tc2_System.T_MaxString; // Holds the failure message of the test END_VAR]]> AlreadyReported); IF NOT AlreadyReported AND (WLEN(STR := Expected) <> WLEN(STR := Actual) OR (Expected <> Actual)) THEN - SetTestFailed(AssertionType := E_AssertionType.Type_WSTRING, - AssertionMessage := Message); + TestMessage := Message; - AssertMessageFormatter.LogAssertFailure(Expected := 'Not possible to print EXP unicode WSTRING value', + TestFailure := AssertMessageFormatter.LogAssertFailure(Expected := 'Not possible to print EXP unicode WSTRING value', Actual := 'Not possible to print ACT unicode WSTRING value', Message := Message, TestInstancePath := TestInstancePath); + + SetTestFailed(AssertionType := E_AssertionType.Type_Array2D_LREAL, + AssertionMessage := TestMessage, + AssertionFailure := TestFailure); END_IF]]> @@ -3838,6 +4047,7 @@ END_IF]]> VAR_INPUT AssertionType : E_AssertionType; AssertionMessage : T_MaxString; + AssertionFailure : Tc2_System.T_MaxString; END_VAR VAR IteratorCounter : UINT; @@ -3852,6 +4062,7 @@ FOR IteratorCounter := 1 TO NumberOfTestsToAnalyse BY 1 DO Tests[IteratorCounter].SetFailed(); Tests[IteratorCounter].SetAssertionType(AssertType := AssertionType); Tests[IteratorCounter].SetAssertionMessage(AssertMessage := AssertionMessage); + Tests[IteratorCounter].SetAssertionFailure(AssertFailure := AssertionFailure); END_IF END_FOR]]> diff --git a/TcUnit/TcUnit/POUs/FB_xUnitXmlPublisher.TcPOU b/TcUnit/TcUnit/POUs/FB_xUnitXmlPublisher.TcPOU index 500bc11..bb4b56f 100644 --- a/TcUnit/TcUnit/POUs/FB_xUnitXmlPublisher.TcPOU +++ b/TcUnit/TcUnit/POUs/FB_xUnitXmlPublisher.TcPOU @@ -82,11 +82,17 @@ VAR UnitTestResults : REFERENCE TO ST_TestSuiteResults; CurrentSuiteNumber : UINT; CurrentTestCount : UINT; + AdjustAssertFailureMessageToMax253CharLength : FB_AdjustAssertFailureMessageToMax253CharLength; + message : Tc2_System.T_MaxString; + FailureMessageLen : INT; + AssertionMessageLen : INT; END_VAR VAR CONSTANT TEST_STATUS_SKIP : STRING := 'SKIP'; TEST_STATUS_PASS : STRING := 'PASS'; TEST_STATUS_FAIL : STRING := 'FAIL'; + MSG_FMT_STRING_MAX_NUMBER_OF_CHARACTERS : INT := 253; + MSG_TOO_LONG : STRING := '...'; END_VAR]]> *) + + FailureMessageLen := Tc2_Standard.LEN(UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureMessage); + AssertionMessageLen := Tc2_Standard.LEN(UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureAssertion); + IF FailureMessageLen = 0 + THEN + message := UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureAssertion; + ELSE + message := CONCAT(UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureMessage, CONCAT('; ', UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureAssertion)); + + IF Tc2_Standard.LEN(message) > MSG_FMT_STRING_MAX_NUMBER_OF_CHARACTERS + THEN + message := Tc2_Standard.LEFT(STR := message, SIZE := (MSG_FMT_STRING_MAX_NUMBER_OF_CHARACTERS - Tc2_Standard.LEN(STR := MSG_TOO_LONG))); + message := Tc2_Standard.CONCAT(STR1 := message, STR2 := MSG_TOO_LONG); + END_IF + END_IF + Xml.NewTag('failure'); - Xml.NewParameter('message', UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureMessage); + Xml.NewParameter('message', message); Xml.NewParameter('type', F_AssertionTypeToString(UnitTestResults.TestSuiteResults[CurrentSuiteNumber].TestCaseResults[CurrentTestCount].FailureType)); (* Close failure tag *) Xml.CloseTag(); diff --git a/TcUnit/TcUnit/TcUnit.plcproj b/TcUnit/TcUnit/TcUnit.plcproj index 6fd1202..fc33fd3 100644 --- a/TcUnit/TcUnit/TcUnit.plcproj +++ b/TcUnit/TcUnit/TcUnit.plcproj @@ -32,7 +32,7 @@ Documentation and examples are available at www.tcunit.org www.tcunit.org Jakob Sagatowski and contributors - 1.2.1.0 + 1.2.2.0 false