Pre-commit hooks for TcUnit library.
Does this:
METHOD TestSomethingElse
-TEST('TestElse')
+TEST('TestSomethingElse')
...
This pre-commit checks if your METHOD
name is the same as name passed to TEST('...')
. This is also how the TcUnit examples are set up.
Your project looks as follows:
MyFunction.TcPOU
MyFunction_Tests.TcPOU
└─ TestSomething()
└─ TestSomethingElse()
Where TestSomething()
looks as follows:
METHOD TestSomething
TEST('TestSomething')
...
If your other methods looks like:
METHOD TestSomethingElse
TEST('TestElse')
...
Then this method is flagged and optionally fixed with the --fix
option: TEST('TestElse')
-> TEST('TestSomethingElse')
Add the following to your existing .pre-commit-config.yml
file or create one.
- 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$'
# 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