UTBot Go automatically generates unit tests for Go programs. Generated tests:
- provide high code coverage and, as a result, its reliability;
- fixate the current behavior of the code as regression tests.
The core principles of UTBot Go are ease of use and maximizing code coverage.
The project is currently under development.
At the moment, only the basic fuzzing technique is supported: namely, the execution of functions on predefined values, depending on the type of parameter.
At the moment, functions are supported, the parameters of which have any primitive types, namely:
boolint,int8,int16,int32,int64uint,uint8,uint16,uint32,uint64byte,rune,stringfloat64,float32complex128,complex64uintptr
For floating point types, correct work with infinities and NaNs is also supported.
Function result types are supported the same as for parameters, but with support for types that implement error.
In addition, UTBot Go correctly captures not only errors returned by functions, but also panic cases.
Examples of supported functions can be found here.
Requirements:
IntelliJ IDEA (Ultimate Edition), compatible with version2022.1;- installed
Go SDKversion compatible with1.19or1.18; - installed in IntelliJ IDEA Go plugin, compatible with the IDE
version (it is for this that the
Ultimateedition of the IDE is needed); - properly configured Go module for source code file (i.e. for file to generate tests for): corresponding
go.modfile must exist.
Most likely, if you are already developing Go project in IntelliJ IDEA, then you have already met all the requirements.
To install the UTBot Go plugin in IntelliJ IDEA:
- just find the latest version of UnitTestBot in the plugin market;
- or download zip archive with
utbot-intellij JARfrom here and install it in IntelliJ IDEA as follows from plugins section (yes, you need to select the entire downloaded zip archive, it does not need to be unpacked).
Finally, you can start using UTBot Go: open any .go file in the IDE and press alt + u, alt + t. After
that, a window will appear in which you can configure the test generation settings and start running it in a couple
of clicks.
Requirements:
- installed
Java SDKversion11or higher; - installed
Go SDKversion compatible with1.19or1.18; - properly configured Go module for source code file (i.e. for file to generate tests for): corresponding
go.modfile must exist.
To install the UTBot Go CLI application: download zip archive containing utbot-cli JAR
from here, then extract its content (JAR file) to a
convenient location.
Finally, you can start using UTBot Go by running the extracted JAR on the command line. For example, to
find out about all flags of UTBot Go CLI application, run the command as follows (utbot-cli-2022.8-beta.jar here is
the path to the extracted JAR).
java -jar utbot-cli-2022.8-beta.jar generateGo --helpUTBot Go CLI application options:
-s, --source TEXT, required: specifies Go source file to generate tests for.-f, --function TEXT: specifies function name to generate tests for. Can be used multiple times to select multiple functions at the same time. If no functions are specified, all functions contained in the source file are selected.-g, --go-path TEXT, required: specifies path to Go executable. For example, it could be/usr/local/go/bin/gofor some systems.-p, --print-test: specifies whether a test should be printed out to StdOut.-w, --overwrite: specifies whether to overwrite the output test file if it already exists.-h, --help: show help message and exit.
If you want to take part in the development of the project or learn more about how it works, check out DEVELOPERS_GUIDE.md.
For the current list of tasks, check out FUTURE_PLANS.md.
Your help and interest is greatly appreciated!