se2p / pynguin

The PYthoN General UnIt Test geNerator is a test-generation tool for Python

Home Page:https://www.pynguin.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR SUT contains nothing we can test.

ThibTrip opened this issue · comments

Problem description

Hello,

I have tried this tool on multiple libraries (private and public) and I cannot get it to work. All I get is this error:

ERROR    SUT contains nothing we can test.

Am I doing something wrong 😕 ?

Code to reproduce

git clone git@github.com:ThibTrip/pangres.git
cd pangres
conda env create -f environment.yml # create the virtual environment
conda activate pangres-dev
pip install pynguin
pynguin --algorithm WHOLE_SUITE --project_path . --output_path ./test_pynguin --module_name pangres

I also tried other commands with the same result.

pynguin --algorithm WHOLE_SUITE --project_path ./pangres --output_path ./test_pynguin --module_name pangres
pynguin --algorithm WHOLE_SUITE --project_path ./pangres --output_path ./test_pynguin --module_name core
pynguin --algorithm WHOLE_SUITE --project_path ./pangres --output_path ./test_pynguin --module_name core.py
commented

Hi,

thanks for your interest in Pynguin :)
For now, Pynguin targets a single module at a time and tries to generate tests for everything that is directly defined in the given module.
In your first command line invocation of Pynguin, you specified the module pangres, this corresponds to the package pangres, i.e., the file pangres/__init__.py, which is used to define the contents of the pangres package. However, since pangres/__init__.py only imports stuff from other modules, Pynguin finds nothing that it can test.
So if you want to test a specific module, e.g. pangres.core, the commad has to be the following, assuming you are in the checked-out git repository:

pynguin --algorithm WHOLE_SUITE --project_path . --output_path ./test_pynguin --module_name pangres.core -v --budget 10

I added -v to get a more verbose output and limited the runtime to 10 seconds --budget 10.
After running this command myself, I noticed that at least for the pangres.core module, Pynguin is unable to achieve any coverage beyond the trivial import coverage.
One of the main reasons for this is probably that the only function in this module (upsert) has no type hints.
Type hints are, for now, a crucial requirement for Pynguin to be able to generate tests.
Otherwise, if Pynguin doesn't know what a valid input for a parameter is, it will simply try random inputs, e.g., lists, ints, floats, etc.

I hope this helps

Best regards
Florian

Hello, sorry for never replying to this ☹️. I actually tried type hinting everything in pangres a while ago but could not get anything out of it. Maybe I'll try this with a simpler library when I have some time. pangres was just for testing purposes, after all the library is already well covered by tests.

Thanks a lot for your help 👍 !