Skip to content

chris-k84/Testing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

check Tc3_UnitTest.library

Unit test Twincat 3, a easy to use unit testing framework Outputs will be stored in standard JUNIT xml file format

Example 1

// Run
fbTestsuites();

IF bExecute THEN
	fbTestsuites.P_Options.sFilePathName:= 'C:\test\report.xml';
	bExecute:= NOT fbTestsuites.M_Request(E_Base.Execute);
END_IF

// Add Testsuite to Testsuites
fbTestsuites.M_Add(fbTestsuite1);
{region "fbTestsuite1"}
// Run
fbTestsuite1();
CASE fbTestsuite1.P_Testcase OF
	E_Testcase.Start:
		// First test case
		fbBuilder.M_Reset().M_Append('Test').M_ToAny(sValue);
		fbTestsuite1.P_Assert.M_IsTRUE(sValue = 'Test', 'FB_StringBuilder.M_Append()');
		fbTestsuite1.M_Testcase('FB_StringBuilder', T#1S, '', '', E_Testcase.Done);	
	E_Testcase.Done:;
	
END_CASE

Example 2

grafik

Resutls

xml format from https://github.com/testmoapp/junitxml

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="" tests="26" failures="2" errors="0" skipped="0" assertions="35" time="2.090" timestamp="2023-10-31T23:43:19.913">
	<testsuite name="" tests="4" failures="0" errors="0" skipped="0" assertions="8" time="0.030" timestamp="2023-10-31T23:43:19.953" file="">
		<testcase name=".M_Testcase_0" classname="FB_ListSTRING" assertions="3" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_1" classname="FB_ListSTRING" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_2" classname="FB_ListSTRING" assertions="3" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_3" classname="FB_ListSTRING" assertions="1" time="0.0100" file="" line="" />
	</testsuite>
	<testsuite name="" tests="9" failures="0" errors="0" skipped="0" assertions="14" time="0.080" timestamp="2023-10-31T23:43:19.953" file="FB_StringBuilder">
		<properties>
			<property name="Property1" value="Value1" />
			<property name="Property2" value="Value2" />
		</properties>
		<testcase name=".M_Testcase_0" classname="FB_StringBuilder" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_1" classname="FB_StringBuilder" assertions="2" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_2" classname="FB_StringBuilder" assertions="2" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_3" classname="FB_StringBuilder" assertions="2" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_4" classname="FB_StringBuilder" assertions="2" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_5" classname="FB_StringBuilder" assertions="2" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_6" classname="FB_StringBuilder" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_7" classname="FB_StringBuilder" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_8" classname="FB_StringBuilder" assertions="1" time="0.0100" file="" line="" />
	</testsuite>
	<testsuite name="" tests="8" failures="0" errors="0" skipped="0" assertions="8" time="0.250" timestamp="2023-10-31T23:43:19.953" file="">
		<testcase name=".M_Testcase_0" classname="FB_File" assertions="1" time="0.0300" file="" line="" />
		<testcase name=".M_Testcase_1" classname="FB_File" assertions="1" time="0.0600" file="" line="" />
		<testcase name=".M_Testcase_2" classname="FB_File" assertions="1" time="0.0300" file="" line="" />
		<testcase name=".M_Testcase_3" classname="FB_File" assertions="1" time="0.0300" file="" line="" />
		<testcase name=".M_Testcase_4" classname="FB_File" assertions="1" time="0.0500" file="" line="" />
		<testcase name=".M_Testcase_5" classname="FB_File" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_6" classname="FB_File" assertions="1" time="0.0200" file="" line="" />
		<testcase name=".M_Testcase_7" classname="FB_File" assertions="1" time="0.0300" file="" line="" />
	</testsuite>
	<testsuite name="" tests="5" failures="2" errors="0" skipped="0" assertions="5" time="2.040" timestamp="2023-10-31T23:43:19.953" file="">
		<testcase name=".M_Testcase_0" classname="FB_Assert" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_1" classname="FB_Assert" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_2" classname="FB_Assert" assertions="1" time="0.0100" file="" line="" />
		<testcase name=".M_Testcase_3" classname="FB_Assert" assertions="1" time="1.0100" file="" line="" >
			<failure message="REAL Array Faied" type="AssertionError">Expected = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.] Actual = [1.1,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]</failure>
		</testcase>
		<testcase name=".M_Testcase_4" classname="FB_Assert" assertions="1" time="1.0100" file="" line="" >
			<failure message="REAL Array Faied" type="AssertionError">Expected = [true,false,false,false,false,false,false,false,false,false,false] Actual = [false,false,false,false,false,false,false,false,false,false,false]</failure>
		</testcase>
	</testsuite>
</testsuites>

grafik

About

A Twincat 3 unit testing library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published