se2p / pynguin

The PYthoN General UnIt Test geNerator is a test-generation tool for Python
https://www.pynguin.eu
MIT License
1.24k stars 75 forks source link

What types of variables can pynguin generate for testcases? #66

Closed Andres981231 closed 5 months ago

Andres981231 commented 5 months ago

Is that pynguin can only generate variables with builtin types for testcases? Can other types from imported modules or user defined types be generated? If providing type annotations?

stephanlukasczyk commented 5 months ago

Hi @Andres981231 ,

Thank you for your interest in Pynguin. It largely depends on the configuration what Pynguin is able to generate. Builtin types are the default, if nothing else is known. Besides, there is a general issue: while a test generator (this is not limited to Pynguin, but also holds for other tools, e.g., EvoSuite) might know about available types from analysing dependencies, it might not be able to construct a sequence of statements that would set up an object of such a type.

The default for Pynguin is that it takes type annotations into account if available (highly recommended, though, because our research [1, 2] has shown that they are beneficial for the test-generation process). It also analyses all imported modules from the subject to have those types available. However, if you could provide me a minimal working example, I could probably tell you the exact reasons for what happens (or does not happen).

Andres981231 commented 5 months ago

Thanks for the replying. After providing type annotations and applying type tracing method, I found that input with most types can be generated correctly.