Skip to content

Commit

Permalink
ci: added unittest and Testbench library
Browse files Browse the repository at this point in the history
  • Loading branch information
seehma committed Jan 2, 2025
1 parent 22dd0f0 commit d0f4e34
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .Zeugwerk/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
"target": "TC3.1",
"configuration": "Distribution",
"distributor-name": "Zeugwerk GmbH"
},
{
"version": "1.0.0.0",
"repository": "bot",
"name": "Testbench",
"branch": "main",
"target": "TC3.1",
"configuration": "Release",
"distributor-name": "Zeugwerk GmbH"
}
],
"references": {
Expand Down
14 changes: 14 additions & 0 deletions src/DeviceInfo/DeviceInfo/DeviceInfo.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<Namespace>Tc3_Module</Namespace>
<QualifiedOnly>true</QualifiedOnly>
</PlaceholderReference>
<PlaceholderReference Include="Testbench">
<DefaultResolution>Testbench, 1.0.0.0 (Zeugwerk GmbH)</DefaultResolution>
<Namespace>Testbench</Namespace>
<QualifiedOnly>true</QualifiedOnly>
</PlaceholderReference>
<PlaceholderReference Include="ZCore">
<DefaultResolution>ZCore, 1.6.0.3 (Zeugwerk GmbH)</DefaultResolution>
<Namespace>ZCore</Namespace>
Expand All @@ -73,6 +78,9 @@
<PlaceholderResolution Include="Tc3_Module">
<Resolution>Tc3_Module, * (Beckhoff Automation GmbH)</Resolution>
</PlaceholderResolution>
<PlaceholderResolution Include="Testbench">
<Resolution>Testbench, 1.0.0.0 (Zeugwerk GmbH)</Resolution>
</PlaceholderResolution>
<PlaceholderResolution Include="ZCore">
<Resolution>ZCore, 1.6.0.3 (Zeugwerk GmbH)</Resolution>
</PlaceholderResolution>
Expand All @@ -94,12 +102,18 @@
<SubType>Code</SubType>
<LinkAlways>true</LinkAlways>
</Compile>
<Compile Include="Tests\SlaveInfoTest.TcPOU">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="DeviceInfo.tmc">
<SubType>Content</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Tests" />
</ItemGroup>
<ProjectExtensions>
<PlcProjectOptions>
<XmlArchive>
Expand Down
25 changes: 25 additions & 0 deletions src/DeviceInfo/DeviceInfo/Tests/SlaveInfoTest.TcPOU
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="SlaveInfoTest" Id="{07648f02-c3bb-4b42-8587-c50362c01051}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK SlaveInfoTest EXTENDS SlaveInfo IMPLEMENTS Testbench.IUnitTest]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="Test_ReadSlaveNamesAsync_CorrectValuesTaken" Id="{4cc048b3-3e23-43a4-8a8e-3d68cc51dd91}">
<Declaration><![CDATA[METHOD Test_ReadSlaveNamesAsync_CorrectValuesTaken
VAR_INPUT
assertions : Testbench.IAssertions;
END_VAR
VAR CONSTANT
amsNetId : Tc2_System.T_AmsNetID := '5.5.5.5.1.1';
deviceId : UDINT := 9;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[ReadSlaveNamesAsync(amsNetId:=amsNetId, deviceId:=deviceId);
assertions.EqualsUdint(expected:=deviceId, actual:=_deviceId, 'Check if Device Id was taken correctly');
assertions.EqualsString(expected:=amsNetId, actual:=_amsNetId, 'Check if Ams Net Id was taken correctly');]]></ST>
</Implementation>
</Method>
</POU>
</TcPlcObject>

0 comments on commit d0f4e34

Please sign in to comment.