Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation improved. #249

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
- [Unit testing concepts](unit-testing-concepts.md)
- [Introduction user guide](introduction-user-guide.md)
- [API](api.md)
-- [Programming example](programming-example.md)
- [Programming example](programming-example.md)
- [Introduction](programming-example-introduction.md)
- [The function blocks](programming-example-the-function-blocks.md)
- [Test cases - Part 1](programming-example-test-cases-part-one)
- [Test cases - Part 2](programming-example-test-cases-part-two)
- [Implementation - Part 1](programming-example-implementation-part-one.md)
- [Implementation - Part 2](programming-example-implementation-part-two.md)
- [Final words](programming-example-final-words.md)
- [Final words](programming-example-final-words.md)
29 changes: 29 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ If you don’t find what you are looking for here, you can look through the:
12. [I have problems running TcUnit on a ARMv7 controller, why?](#_12-i-have-problems-running-tcunit-on-a-armv7-controller-why)
13. [AssertEquals(ANY) on properties makes my development environment crash, why?](#_13-assertequalsany-on-properties-makes-my-development-environment-crash-why)
14. [Why can't I pass a variable in VAR_INST into another?](#_14-why-can39t-i-pass-a-variable-in-var_inst-into-another)
15. [Why is each message printed twice (or many times)?](#_15-why-is-each-message-printed-twice-or-many-times)

---

Expand Down Expand Up @@ -413,3 +414,31 @@ END_IF

- If your test function block will only have one instance, you can use `VAR_STAT` instead.
Like `VAR_INST`, `VAR_STAT` will retain changes between cycles, but the values will be the same across all instances of the FB.

## 15. Why is each message printed twice (or many times)?

Each message is printed twice (or many times) to the Error List of Visual Studio.
Why? What is going wrong here?

This problem is described in the following GitHub issue:
- [#92: Duplicate event message output in multi-project solutions](https://github.com/tcunit/TcUnit/issues/92)

Duplicates of this issue:
- [#125: Duplicate messages presented in error list](https://github.com/tcunit/TcUnit/issues/125)
- [#235: Tests seem to run 4 times](https://github.com/tcunit/TcUnit/issues/235)
- [#246: Double execution of TcUnit](https://github.com/tcunit/TcUnit/issues/246)
- [#248: Each message is printed multiple times in the XAE instance, and in every XAE instance](https://github.com/tcunit/TcUnit/issues/248)

It happens when the solution contains multple projects.
The messages are printed as often as the number of projects that exist in the solution.

When the messages are printed multiple times. they may be ordered:
(Example from [Issue 92](https://github.com/tcunit/TcUnit/issues/92), image copied: TwinCAT 3.1.4022.22, TcUnit v.1.0.0, 3 projects in solution, thus each message is printed 3 times)
![](img/TcUnitDuplicateMessages1.png)

or completely unordered:
(Example from [Issue 248](https://github.com/tcunit/TcUnit/issues/248), image added here independently: TwinCAT 3.1.4026.10, TcUnit v.1.3.1, 20 projects in solution, thus each message is printed 20 times)
![](img/TcUnitDuplicateMessages2.png)

The reason for this behaviour is explained in [Issue 92](https://github.com/tcunit/TcUnit/issues/92).
Unfortunately, there is no solution or workaround for this problem yet.
Binary file added docs/img/TcUnitDuplicateMessages1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/TcUnitDuplicateMessages2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 20 additions & 5 deletions docs/introduction-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@ For a more thorough/detailed example please see the [programming example](progra

The purpose of this user guide is to be a short tutorial where we will go through the different steps to that are necessary to use TcUnit, which are:

1. Download and install the TcUnit framework on your engineering PC
2. Reference the library in your project
3. Create test suites and run the tests
1. Create the library project that is going to be tested
2. Download and install the TcUnit framework on your engineering PC
3. Reference the TcUnit library in your project
4. Create test suites and run the tests

## Create your library to be tested

You may already have a library in which you want to add unit tests, so why create another one?

The reason is, your library probably is not suitable for executing unit tests.
The Beckhoff documentation on [Library creation](https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/4189255051.html) recommends using an "Empty PLC Project".
An empty PLC project however can only be saved as a library and cannot be run itself in the TwinCAT runtime.
If you followed this recommendation and created your library based on an empty PLC project, you will not be able to execute any programs in this project, because the whole system-related part is missing.
In this case you need to create a new "TwinCAT XAE Project (XML format)" and move your library code.

If you want to keep your empty PLC project as the base of your library, then you still need to create another TwinCAT XAE project in which you will put your unit tests code.

This of course is not necessary if you already have a XAE project or your library is based on one.

## Download & install

Expand Down Expand Up @@ -46,7 +61,7 @@ Make sure that the **file format** drop-down menu is set to **Library files (*.l
This will install the library on your computer.
Once the library is installed, the file that you saved on the desktop can be removed.

### Reference the library in project
## Reference the library in project

In order to use TcUnit you need to add a reference to the library in your project.
Open your TwinCAT project, and right-click on the **References** under the PLC-project and click on **Add library...**
Expand All @@ -55,7 +70,7 @@ Open your TwinCAT project, and right-click on the **References** under the PLC-p

Next go to the TcUnit-group, select TcUnit and click **OK**.

### Create test suites and run them
## Create test suites and run them

For every function block (or free function) that you have defined we want to create a test function block (test suite), which has the responsibility to:

Expand Down