Skip to content

Commit 2354abe

Browse files
authored
update test readme (#172)
1 parent 6dd688c commit 2354abe

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tests/README.rst

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ Unit tests
1919

2020
Unit tests are located under utest/ directory. Test for particular file are located under test_<filename>.py.
2121
Common methods are stored in utest/utils.py. For running the robotidy itself (through cli) we can use ``run_tidy``
22-
method. To stop robotidy from overwriting the source file we need to add to our test class monkey patch method for
23-
saving output::
24-
25-
@patch('robotidy.app.Robotidy.save_model', new=save_tmp_model)
22+
method.
2623

2724
You can run tests by running::
2825

@@ -31,36 +28,29 @@ You can run tests by running::
3128
Acceptance tests
3229
----------------
3330

34-
Acceptance tests are located under atest/ directory. Tests for transformers are defined in ``test_transformers.py``
35-
file. You can add tests for transformer by creating test class and prefixing it with::
36-
37-
@patch('robotidy.app.Robotidy.save_model', new=save_tmp_model)
38-
39-
It will monkey patch the robotidy method for saving the output. In that way our source files will not be overwritten
40-
and output will be written to actual/ directory instead. Test data should be stored in directory with the same name as
41-
transformation (ie. ``DiscardEmptySections\``). Source files should go to ``source`` directory and expected files to
42-
``expected`` directory.
31+
Acceptance tests are located under atest/ directory. There is separate directory for each transformer. Tests for
32+
transformers are defined in ``test_transformer.py`` file under each directory. In the same directory test data is stored.
33+
Source files should go to ``source`` directory and expected files to ``expected`` directory.
4334

4435
You can add test methods and then run tidy against your source code using::
4536

46-
run_tidy_and_compare(transformer_name: str, sources: List[str],
47-
expected: Optional[List[str]] = None, config: str = ''):
37+
run_tidy_and_compare(transformer_name: str, source: str, expected: Optional[str] = None, config: str = ''):
4838

4939
Transformer name and list of sources are mandatory. Here is minimal example::
5040

51-
run_tidy_and_compare('MyTransformer', ['test.robot'])
41+
run_tidy_and_compare('MyTransformer', 'test.robot')
5242

5343
It will execute following:
5444

5545
robotidy --transform MyTransformer MyTransformer/test.robot
5646

57-
If you did not provide expected filenames list it will use source list (meaning that for ``test.robot`` found in
47+
If you did not provide expected filename it will use source name (meaning that for ``test.robot`` found in
5848
``source`` expected file will be ``test.robot`` stored in ``expected``).
5949

6050
You can use the same source name with different transformer option and different expected files. For example::
6151

62-
run_tidy_and_compare('MyTransformer', ['test.robot'], ['option1.robot'], config=':option1=True')
63-
run_tidy_and_compare('MyTransformer', ['test.robot'], ['option2.robot'], config=':option2=True')
52+
run_tidy_and_compare('MyTransformer', 'test.robot', 'option1.robot', config=':option1=True')
53+
run_tidy_and_compare('MyTransformer', 'test.robot', 'option2.robot', config=':option2=True')
6454

6555
It's equivalent of executing::
6656

0 commit comments

Comments
 (0)