Skip to content

Commit cafd6a5

Browse files
committed
Further work on the documentation. Added new page for download instructions. Ran the markdown through a linter.
1 parent bb35db2 commit cafd6a5

12 files changed

Lines changed: 282 additions & 57 deletions

CONTRIBUTING.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Contributing to TcUnit
2+
23
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
34

45
- Reporting a bug
@@ -8,9 +9,11 @@ We love your input! We want to make contributing to this project as easy and tra
89
- Becoming a maintainer
910

1011
## We Develop with Github
12+
1113
We use github to host code, to track issues and feature requests, as well as accept pull requests.
1214

1315
## We Use [Github Flow](https://docs.github.com/en/get-started/quickstart/github-flow), So All Code Changes Happen Through Pull Requests
16+
1417
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:
1518

1619
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
2023
5. Issue that pull request!
2124

2225
## Any contributions you make will be under the MIT Software License
26+
2327
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.
2428

2529
## Report bugs using Github's [issues](https://github.com/tcunit/TcUnit/issues)
30+
2631
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!
2732

2833
## 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]
3843
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
3944

4045
## 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=))
4551

4652
## License
53+
4754
By contributing, you agree that your contributions will be licensed under the MIT License.
4855

4956
## References
57+
5058
This document was adapted from briandk's excellent [contribution guidelines template](https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62).

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/tcunit/TcUnit/blob/master/LICENSE)
33
[![Open Source? Yes!](https://badgen.net/badge/Open%20Source%20%3F/Yes%21/blue?icon=github)](https://github.com/TcUnit/TcUnit)
44

5-
65
# TcUnit - TwinCAT unit testing framework
76

87
Welcome to the documentation TcUnit - an xUnit testing framework for [Beckhoff's TwinCAT3](https://www.beckhoff.com/twincat3/).
@@ -11,7 +10,7 @@ Welcome to the documentation TcUnit - an xUnit testing framework for [Beckhoff's
1110
**[www.tcunit.org](https://www.tcunit.org)**
1211

1312
**What is test driven development and unit testing?**
14-
Familiarize yourself with [the basic concepts and specifics for TcUnit](https://tcunit.org/unit-testing-concepts/).
13+
Familiarize yourself with [the basic concepts and specifics for TcUnit](https://tcunit.org/unit-testing-concepts/).
1514

1615
**Want to know how to get started?**
1716
Read the [user guide](https://tcunit.org/introduction-user-guide/).
@@ -32,4 +31,4 @@ That's fantastic! But please read the [CONTRIBUTING](CONTRIBUTING.md) first.
3231
Check the [F.A.Q](https://tcunit.org/frequently-asked-questions/).
3332
Check the [open](https://github.com/tcunit/TcUnit/issues) and [closed](https://github.com/tcunit/TcUnit/issues?q=is%3Aissue+is%3Aclosed) issues.
3433
If your issue does not already exist, create a [new](https://github.com/tcunit/TcUnit/issues/new).
35-
For general ideas/discussions, use the [discussions](https://github.com/tcunit/TcUnit/discussions).
34+
For general ideas/discussions, use the [discussions](https://github.com/tcunit/TcUnit/discussions).

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ header_pages:
3737
- unit-testing-concepts.md
3838
- programming-example.md
3939
- faq.md
40+
- download.md
4041

4142
# Exclude from processing.
4243
# The following items will not be processed, by default.

docs/download.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
layout: page
3+
title: Download
4+
---
5+
6+
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).
40.8 KB
Loading
4.97 KB
Loading
4.97 KB
Loading
39.9 KB
Loading

docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ layout: home
66
list_title: ' '
77
---
88

9-
# TcUnit
10-
119
![TcUnit logo](img/tcunit-logo.png)
1210

13-
TcUnit is an [xUnit](https://en.wikipedia.org/wiki/XUnit) type of framework specifically done for [Beckhoffs 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.
1412
It consists of a single library that is easily integrated into any existing TwinCAT 3 project.
1513

1614
**Want to get started?**
@@ -36,5 +34,5 @@ The software is completely free and you can use the software in any way you want
3634

3735
## Automated test runs
3836

39-
With the additional TcUnit-Runner software, its 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.
4038
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).

docs/introduction-user-guide.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: page
33
title: Introduction user guide
44
---
55

6-
Before reading this guide, its 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.
77

88
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.
99
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
2222

2323
### Install from library file
2424

25-
If youve 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.
2626
Start your TwinCAT XAE (Visual Studio).
2727
In the menu of Visual Studio select **PLC** and then **Library Repository...**
2828
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
6262
- Define the inputs
6363
- Define the expected outputs (result)
6464
- Call the TcUnit-assert methods to compare the expected output to the actual output for every test
65-
Its 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.
6666
On the same level as the `POUs` folder, create a folder called `Test`.
67-
Its 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.
6868

6969
![Test FBs](img/test-fbs.png)
7070

7171
In this example we have a total of five FBs.
7272
For every FB we have created a test-FB, i.e. for `FB_DiagnosticMessageDiagnosticCodeParser` we have `FB_DiagnosticMessageDiagnosticCodeParser_Test`.
7373
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 its 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 its better to structure the code in various library projects each responsible for a certain set of requirements/functionality.
76-
Its 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.
7777

7878
![TcUnit architecture](img/tcunit-arch.png)
7979

8080
The general structure here is that `PRG_TEST` is the program in where the test-FBs (test suites) are instantiated.
8181
Each test suite is responsible of testing one FB or function, and can have one or more tests to do so.
8282

83-
Lets 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 weve 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.
8585

8686
```StructuredText
8787
FUNCTION_BLOCK FB_Sum
@@ -94,7 +94,7 @@ VAR_OUTPUT
9494
END_VAR
9595
```
9696

97-
Now lets create the test suite for this.
97+
Now let's create the test suite for this.
9898
This FB needs to extend `TcUnit.FB_TestSuite`.
9999

100100
```StructuredText
@@ -105,12 +105,12 @@ END_VAR
105105

106106
By always adding this code, your test suite gets access to TcUnit and TcUnit will have a handle to your test suites.
107107

108-
Now its time to create our tests.
108+
Now it's time to create our tests.
109109
There are many ways to structure your tests, and there are several guidelines for this as well.
110-
What well be doing is to create a method for every test, and name it in such a way that its 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.
111111
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).
112112
For them well-named tests are invaluable.
113-
Well be creating two tests called `TwoPlusTwoEqualsFour` and `ZeroPlusZeroEqualsZero`.
113+
We'll be creating two tests called `TwoPlusTwoEqualsFour` and `ZeroPlusZeroEqualsZero`.
114114
The `TwoPlusTwoEqualsFour` will look like this:
115115

116116
```StructuredText
@@ -139,7 +139,7 @@ The Message parameter is optional and is used in case the assertion fails, the t
139139
We finish the method by calling `TEST_FINISHED()`.
140140
This gives the flexibility to have tests that span over more than one PLC-cycle.
141141

142-
For `ZeroPlusZeroEqualsZero` its more or less the same code.
142+
For `ZeroPlusZeroEqualsZero` it's more or less the same code.
143143

144144
```StructuredText
145145
METHOD ZeroPlusZeroEqualsZero
@@ -194,8 +194,8 @@ Activating this solution and running it results in the following result in the v
194194
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.
195195
But how come that we have one test succeeding?
196196
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 havent written the body of `FB_Sum` the test will succeed.
198-
Lets 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`.
199199

200200
```StructuredText
201201
FUNCTION_BLOCK FB_Sum

0 commit comments

Comments
 (0)