You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
# Contributing to TcUnit
2
+
2
3
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
3
4
4
5
- Reporting a bug
@@ -8,9 +9,11 @@ We love your input! We want to make contributing to this project as easy and tra
8
9
- Becoming a maintainer
9
10
10
11
## We Develop with Github
12
+
11
13
We use github to host code, to track issues and feature requests, as well as accept pull requests.
12
14
13
15
## We Use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow), So All Code Changes Happen Through Pull Requests
16
+
14
17
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow)). We actively welcome your pull requests:
15
18
16
19
1. Fork the repo and create your branch from `master`.
@@ -20,9 +23,11 @@ Pull requests are the best way to propose changes to the codebase (we use [Githu
20
23
5. Issue that pull request!
21
24
22
25
## Any contributions you make will be under the MIT Software License
26
+
23
27
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
24
28
25
29
## Report bugs using Github's [issues](https://github.com/tcunit/TcUnit/issues)
30
+
26
31
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/tcunit/TcUnit/issues/new); it's that easy!
27
32
28
33
## Write bug reports with detail, background, and sample code
@@ -38,13 +43,16 @@ We use GitHub issues to track public bugs. Report a bug by [opening a new issue]
38
43
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
39
44
40
45
## Use a Consistent Coding Style
41
-
* Make sure to edit the project with the same version of Visual Studio as the master branch. All software (TcUnit and TcUnit-Verifier) has been developed using Visual Studio 2019. Note that the TwinCAT XAE Shell (provided with TwinCAT XAE installer) can't open the TcUnit-Verifier_DotNet (as it's a .NET/C# project). Instead it's recommended to use [VS2019 community edition](https://visualstudio.microsoft.com/vs/older-downloads/) which can be used both for TwinCAT and .NET/C# projects
42
-
* Make sure to use TwinCAT XAE version 3.1.4024.44 or later
43
-
* The prefixes of naming of function blocks/variables/etc from the [Beckhoff TwinCAT3 identifier/name conventions](https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/18014401873267083.html&id=) are ignored as a modern integrated development environment (as Visual Studio) gives all the hints/information of data types etc
44
-
* Make sure to set your TwinCAT development environment to use Separate LineIDs. This is available in the TwinCAT XAE under **Tools→Options→TwinCAT→PLC Environment→Write options→Separate LineIDs** (set this to TRUE, more information is available [here](https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_userinterface/18014403202147467.html&id=))
46
+
47
+
- Make sure to edit the project with the same version of Visual Studio as the master branch. All software (TcUnit and TcUnit-Verifier) has been developed using Visual Studio 2019. Note that the TwinCAT XAE Shell (provided with TwinCAT XAE installer) can't open the TcUnit-Verifier_DotNet (as it's a .NET/C# project). Instead it's recommended to use [VS2019 community edition](https://visualstudio.microsoft.com/vs/older-downloads/) which can be used both for TwinCAT and .NET/C# projects
48
+
- Make sure to use TwinCAT XAE version 3.1.4024.44 or later
49
+
- The prefixes of naming of function blocks/variables/etc from the [Beckhoff TwinCAT3 identifier/name conventions](https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/18014401873267083.html&id=) are ignored as a modern integrated development environment (as Visual Studio) gives all the hints/information of data types etc
50
+
- Make sure to set your TwinCAT development environment to use Separate LineIDs. This is available in the TwinCAT XAE under **Tools→Options→TwinCAT→PLC Environment→Write options→Separate LineIDs** (set this to TRUE, more information is available [here](https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_userinterface/18014403202147467.html&id=))
45
51
46
52
## License
53
+
47
54
By contributing, you agree that your contributions will be licensed under the MIT License.
48
55
49
56
## References
57
+
50
58
This document was adapted from briandk's excellent [contribution guidelines template](https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62).
TcUnit can be downloaded as either a [pre-compiled library](https://github.com/tcunit/TcUnit/releases) or [as source code](https://github.com/tcunit/TcUnit).
7
+
For a tutorial on how you install TcUnit from either a downloaded library or from source read the [introduction user guide](introduction-user-guide.md).
8
+
The libraries are compatible with TwinCAT **3.1.4020.0** or newer.
9
+
10
+
Release history
11
+
All releases can be downloaded from the official [TcUnit release site](https://github.com/tcunit/TcUnit/releases).
Copy file name to clipboardExpand all lines: docs/index.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,9 @@ layout: home
6
6
list_title: ''
7
7
---
8
8
9
-
# TcUnit
10
-
11
9

12
10
13
-
TcUnit is an [xUnit](https://en.wikipedia.org/wiki/XUnit) type of framework specifically done for [Beckhoff’s TwinCAT 3](https://www.beckhoff.com/en-en/products/automation/twincat/) development environment.
11
+
TcUnit is an [xUnit](https://en.wikipedia.org/wiki/XUnit) type of framework specifically done for [Beckhoff's TwinCAT 3](https://www.beckhoff.com/en-en/products/automation/twincat/) development environment.
14
12
It consists of a single library that is easily integrated into any existing TwinCAT 3 project.
15
13
16
14
**Want to get started?**
@@ -36,5 +34,5 @@ The software is completely free and you can use the software in any way you want
36
34
37
35
## Automated test runs
38
36
39
-
With the additional TcUnit-Runner software, it’s possible to do integrate all your TcUnit tests into a CI/CD software toolchain.
37
+
With the additional TcUnit-Runner software, it's possible to do integrate all your TcUnit tests into a CI/CD software toolchain.
40
38
With the aid of automation software such as [Jenkins](https://www.jenkins.io/) or [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/), you can have your tests being run automatically and collect test statistics every time something is changed in your software version control (such as Git or Subversion).
Copy file name to clipboardExpand all lines: docs/introduction-user-guide.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ layout: page
3
3
title: Introduction user guide
4
4
---
5
5
6
-
Before reading this guide, it’s highly recommended to read [unit testing concepts](unit-testing-concepts.md), in order to have a basic understanding of the concepts of unit testing and TcUnit.
6
+
Before reading this guide, it's highly recommended to read [unit testing concepts](unit-testing-concepts.md), in order to have a basic understanding of the concepts of unit testing and TcUnit.
7
7
8
8
The TcUnit framework gives you the possibility to easily write unit tests for your TwinCAT 3 software, and having the results reported in a human-readable format for review.
9
9
All unit test code is written in the same program/library as the rest of your code, but because it is only used in a separate test-program, it does not affect the production code/executables.
@@ -22,7 +22,7 @@ The framework can either be downloaded as a [precompiled library](https://github
22
22
23
23
### Install from library file
24
24
25
-
If you’ve downloaded the library, you should have a file called **TcUnit.library** in your computer.
25
+
If you've downloaded the library, you should have a file called **TcUnit.library** in your computer.
26
26
Start your TwinCAT XAE (Visual Studio).
27
27
In the menu of Visual Studio select **PLC** and then **Library Repository...**
28
28
This will display the following window:
@@ -62,26 +62,26 @@ For every function block (or free function) that you have defined we want to cre
62
62
- Define the inputs
63
63
- Define the expected outputs (result)
64
64
- Call the TcUnit-assert methods to compare the expected output to the actual output for every test
65
-
It’s entirely up to the user how to to organize the different tests, so what follows is a best practice/suggestion.
65
+
It's entirely up to the user how to to organize the different tests, so what follows is a best practice/suggestion.
66
66
On the same level as the `POUs` folder, create a folder called `Test`.
67
-
It’s in this folder that we will create all our test FBs as well as the program that will run the TcUnit framework.
67
+
It's in this folder that we will create all our test FBs as well as the program that will run the TcUnit framework.
68
68
69
69

70
70
71
71
In this example we have a total of five FBs.
72
72
For every FB we have created a test-FB, i.e. for `FB_DiagnosticMessageDiagnosticCodeParser` we have `FB_DiagnosticMessageDiagnosticCodeParser_Test`.
73
73
Note that the framework in no way enforces to use any standard for the naming, this is entirely up to the user.
74
-
For various reasons you might find it’s not even possible to add the test-FBs in the same solution (for instance, if this is your main executable), and in this case just put the tests in a separate solution and include the main solution in the test solution as a library.
75
-
Generally it’s better to structure the code in various library projects each responsible for a certain set of requirements/functionality.
76
-
It’s important to see the tests as an important part of your code.
74
+
For various reasons you might find it's not even possible to add the test-FBs in the same solution (for instance, if this is your main executable), and in this case just put the tests in a separate solution and include the main solution in the test solution as a library.
75
+
Generally it's better to structure the code in various library projects each responsible for a certain set of requirements/functionality.
76
+
It's important to see the tests as an important part of your code.
77
77
78
78

79
79
80
80
The general structure here is that `PRG_TEST` is the program in where the test-FBs (test suites) are instantiated.
81
81
Each test suite is responsible of testing one FB or function, and can have one or more tests to do so.
82
82
83
-
Let’s assume we want to create the simplest possible FB that takes two unsigned integers and sums them.
84
-
We can create the header for the FB, but the actual implementation can (and should) wait after we’ve done the unit tests.
83
+
Let's assume we want to create the simplest possible FB that takes two unsigned integers and sums them.
84
+
We can create the header for the FB, but the actual implementation can (and should) wait after we've done the unit tests.
85
85
86
86
```StructuredText
87
87
FUNCTION_BLOCK FB_Sum
@@ -94,7 +94,7 @@ VAR_OUTPUT
94
94
END_VAR
95
95
```
96
96
97
-
Now let’s create the test suite for this.
97
+
Now let's create the test suite for this.
98
98
This FB needs to extend `TcUnit.FB_TestSuite`.
99
99
100
100
```StructuredText
@@ -105,12 +105,12 @@ END_VAR
105
105
106
106
By always adding this code, your test suite gets access to TcUnit and TcUnit will have a handle to your test suites.
107
107
108
-
Now it’s time to create our tests.
108
+
Now it's time to create our tests.
109
109
There are many ways to structure your tests, and there are several guidelines for this as well.
110
-
What we’ll be doing is to create a method for every test, and name it in such a way that it’s clear what the test does.
110
+
What we'll be doing is to create a method for every test, and name it in such a way that it's clear what the test does.
111
111
Remember that the unit tests are part of the documentation of your code, and although you might find the code trivial at this moment, there might be other developers reading your code now (or many years in the future).
112
112
For them well-named tests are invaluable.
113
-
We’ll be creating two tests called `TwoPlusTwoEqualsFour` and `ZeroPlusZeroEqualsZero`.
113
+
We'll be creating two tests called `TwoPlusTwoEqualsFour` and `ZeroPlusZeroEqualsZero`.
114
114
The `TwoPlusTwoEqualsFour` will look like this:
115
115
116
116
```StructuredText
@@ -139,7 +139,7 @@ The Message parameter is optional and is used in case the assertion fails, the t
139
139
We finish the method by calling `TEST_FINISHED()`.
140
140
This gives the flexibility to have tests that span over more than one PLC-cycle.
141
141
142
-
For `ZeroPlusZeroEqualsZero` it’s more or less the same code.
142
+
For `ZeroPlusZeroEqualsZero` it's more or less the same code.
143
143
144
144
```StructuredText
145
145
METHOD ZeroPlusZeroEqualsZero
@@ -194,8 +194,8 @@ Activating this solution and running it results in the following result in the v
194
194
There is one test that has failed, and the reason for this is that we have not written the implementation code yet, only the header of the function block FB_Sum.
195
195
But how come that we have one test succeeding?
196
196
As we can see, the test `TwoPlusTwoEqualsFour` failed, which means that the one that succeeded was the other test `ZeroPlusZeroEqualsZero`.
197
-
The reason this succeeds is that the default return value for an output-parameter is zero, and thus it means that even if we haven’t written the body of `FB_Sum` the test will succeed.
198
-
Let’s finish by implementing the body of `FB_Sum`.
197
+
The reason this succeeds is that the default return value for an output-parameter is zero, and thus it means that even if we haven't written the body of `FB_Sum` the test will succeed.
198
+
Let's finish by implementing the body of `FB_Sum`.
0 commit comments