Closed TaicaiChen closed 8 months ago
Pynguin's test generation algorithms are based on probabilistic decisions. Thus, the resulting test cases can differ between tool executions. In order to mitigate this, one can set a seed for the involved random-number generator (CLI option --seed
). As a result, the generated output should be the same every time one executes Pynguin with the same seed value.
Independent of the annotated type information, Pynguin might (on random basis) decide to also try to use other types for the parameter values to increase the coverage even further. Consider an example function:
def foo(a: int):
if isinstance(a, str):
raise ValueError()
Such a guarding type check is something that we've seen in many Python functions. However, to cover the raise ValueError()
statement, one needs to deliberately call foo
with an object of a non-annotated type (str
instead of int
in the example). In order to be able to do so, Pynguin chooses also non-annotated types with some probability.
Describe the bug A clear and concise description of what the bug is. When running the example.py in the quick start guide, although the example provides type annotation information for input and output data (input is int, output is str), the generated unit test code still includes test cases with non-int inputs. And when using type4py to obtain type information, it also does not take effect. To Reproduce Steps to reproduce the behaviour:
Expected behavior All generated unit test cases have input types as int, just as shown in the official documentation.
Screenshots The generated unit test cases: The expected generated unit test cases:
Software Version (please complete the following information):