Unit testing framework for LabVIEW™
Explore the docs »
View Demo
Report Bug
Request Feature
LVUnit is a unit testing framework for LabVIEW™.
To get a local copy up and running follow these simple steps.
- LabVIEW™ 2017 or later
- VI Package Manager
- Clone the repo
git clone https://github.com/logmanoriginal/lvunit.git
- Install packages
Or apply
start .vipc
.vipc
manually.
You can open Test Explorer from the Tools menu or via the Quick Drop Shortcut 'Ctrl+E'.
Theories are test cases that can be executed with different data sets.
To create a theory, simply add controls to the connector pane.
To define data sets for your theory, place a JSON file with the same file name in the same folder as the test case.
For example:
- Theory1.vi
- Theory1.json
The JSON file has the following syntax:
[
{
"name": "Message 1",
"data": {
"expected": "Failed asserting that...",
"message": "Failed asserting that..."
}
},
{
"name": "Message 2",
"data": {
"expected": "Test failed!",
"message": "Test failed!"
}
}
]
Use Test Explorer to discover and execute all theories in your project. Notice that an entry is added for each data set in your theory.
- LVUnit can be used from LabVIEW CLI to generate test and coverage reports from your CI/CD pipeline. See the
Test
operation in the Toolchain directory for a working example. - You can open a test case directly from Test Explorer by double-clicking on the test case in the tree. For theories, you need to double-click on one of its data sets. This will populate the theory with the selected data set for your convenience.
- Test Explorer categorizes test cases based on their qualified name. You can place test cases in project libraries and Test Explorer will categorize them accordingly.
- Test cases must be public. You can disable a test case by changing the scope (or the scope of its parent) to private.
- Test cases that return an error at the error output terminal are considered failed. This includes any error that isn't a result of an assertion.
- Test Explorer automatically discovers tests in your project. When you select a different project, Test Explorer scans the new project automatically.
- Test Explorer supports code coverage. You can export code coverage data to a Covertura XML file. Note, however, that code coverage in LabVIEW is very limited and does not work right for VIMs, polymorphic VIs, and various other file types. Code coverage is reported as "lines" (because Cobertura has no concept for nodes) where the coverage percentage is reported as x/100 lines. This is a quick hack that is likely to change in the future. Use code coverage with caution. See the build pipeline for LVUnit for an example of how code coverage reports can be integrated into an CI/CD pipeline.
See open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place. Any contributions you make are greatly appreciated 💖
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Keep in mind that LabVIEW™ VIs are binary files, which are difficult to merge.
- Only change a single VI or library.
- Avoid conflicts with other pull requests (don't work on the same libraries or VIs).
- Send VI Snippets (via issues) instead of pull requests when possible.
Distributed under the BSD-3-Clause license. See LICENSE for more information.
Project Link: https://github.com/logmanoriginal/lvunit