bmw-software-engineering / lobster

Lightweight Open BMW Software Traceability Evidence Report
GNU Affero General Public License v3.0
12 stars 6 forks source link

lobster-python duplicates tests if using unittest #20

Closed phiwuu closed 6 months ago

phiwuu commented 6 months ago

If lobster-python runs over a Python project where unittest is used instead of pytest, then each test is also interpreted as a regular function. This leads to the result that the final lobster report shows each unit test twice (as a function and as a test).

We need to check if this happens only for unittest, or also for pytest.

florianschanda commented 6 months ago

Are you using the --activity flag for lobster-python to get the tests? And are you making sure that lobster-python is run twice, once for the code (making sure that the tests are not accidentally passed) and once with --activity for the tests?

So if you have a dir structure like this:

my_module
tests

Then you should run it like so:

$ lobster-python my_module --out=code.lobster
$ lobster-python --activity tests --out=test.lobster
phiwuu commented 6 months ago

I see. Then it was indeed my mistake. I ran lobster-python over the tests folder, too, without the `--activity' flag, and was expecting that it ignores the tests. I will update the readme file accordingly.

florianschanda commented 6 months ago

Right - so if you run without --activity then any test just looks like some random class extension, there is no real way for the tool to tell.

I'll kill the ticket now since I hope this is resolved?