Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rruiter87/tcunit-precommit
Pre-commit hooks for the TcUnit library
https://github.com/rruiter87/tcunit-precommit
beckhoff plc-programming twincat3 unittest
Last synced: about 2 months ago
JSON representation
Pre-commit hooks for the TcUnit library
- Host: GitHub
- URL: https://github.com/rruiter87/tcunit-precommit
- Owner: rruiter87
- License: mit
- Created: 2024-06-11T13:46:23.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-04T21:02:12.000Z (2 months ago)
- Last Synced: 2024-11-04T22:17:53.532Z (2 months ago)
- Topics: beckhoff, plc-programming, twincat3, unittest
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TcUnit pre-commit
Pre-commit hooks for [TcUnit](https://tcunit.org/) library.
Does this:
```diff
METHOD TestSomethingElse-TEST('TestElse')
+TEST('TestSomethingElse')
...
```## What it does
This pre-commit checks if your `METHOD` name is the same as name passed to `TEST('...')`. This is also how the [TcUnit examples](https://tcunit.org/#/introduction-user-guide?id=create-test-suites-and-run-them) are set up.
Your project looks as follows:
```
MyFunction.TcPOU
MyFunction_Tests.TcPOU
└─ TestSomething()
└─ TestSomethingElse()
```Where `TestSomething()` looks as follows:
```
METHOD TestSomethingTEST('TestSomething')
...
```If your other methods looks like:
```
METHOD TestSomethingElseTEST('TestElse')
...
```Then this method is flagged and optionally fixed with the `--fix` option: `TEST('TestElse')` -> `TEST('TestSomethingElse')`
## Usage
Add the following to your existing `.pre-commit-config.yml` file or create one.
```yaml
- repo: https://github.com/rruiter87/tcunit-precommit
rev: v0.2.0
hooks:
- id: unittest-name-fixer
# --fix: fixes non-matching method - test names
args: [--fix]
# Only check files that end in _Tests.TcPOU, because that is how I name my tests
files: '.*_Tests\.TcPOU$'
```## Developers
```bash
# Create conda environment with necessary dependencies
conda env create -f conda.yml
# activate environment
conda activate tcunit-pc312
# Install development dependencies
pip install --requirement dev-requirements.txt
# Install CLI in editable mode, that way any chages you make to the code are
# directly reflected if you run unittest-name-fixer from the command line
pip install --editable .
# Install/activate pre-commits of this repo. Assumes you have pre-commit installed globally
pre-commit install
```