Skip to content

Commit c1e9f60

Browse files
authored
Update UnitTestBot Go docs (#2283)
* Update Go docs * Fix remarks
1 parent 2eefc9e commit c1e9f60

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

docs/GoSupport.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ UnitTestBot Go automatically generates ready-to-use unit tests for Go programs.
55
With UnitTestBot Go, you can find bugs in your code and fixate the desired program behavior with less effort.
66

77
The project is under development,
8-
so feel free to [contribute](https://github.com/UnitTestBot/UTBotJava/blob/main/utbot-go/docs/DEVELOPERS_GUIDE.md).
8+
so feel free to [contribute](https://github.com/UnitTestBot/UTBotJava/blob/main/utbot-go/docs/DEVELOPER_GUIDE.md).
99

1010
## Features and details
1111

@@ -15,14 +15,14 @@ inserts these values into the user functions, and executes the resulting test ca
1515

1616
### Supported types for function parameters
1717

18-
Now UnitTestBot Go can generate values for _primitive types_, _arrays_, _slices_ and _structs_.
18+
Now UnitTestBot Go can generate values for _primitive types_, _arrays_, _slices_, _maps_, _structs_, _channels_, _interfaces_, and _pointers_.
1919

2020
For _floating point types_, UnitTestBot Go supports working with _infinity_ and _NaN_.
2121

2222
### Supported types for the returned results
2323

2424
For the returned function results,
25-
UnitTestBot Go supports the `error` type as well as all the types supported for the function parameters.
25+
UnitTestBot Go supports the `error` type as well as all the types supported for the function parameters except _interfaces_ and _channels_.
2626

2727
It also captures `panic` cases correctly.
2828

@@ -85,7 +85,7 @@ Please refer to [UnitTestBot user guide](https://github.com/UnitTestBot/UTBotJav
8585

8686
### Requirements
8787

88-
* Java SDK 11 or later
88+
* Java SDK 17 or later
8989
* Go SDK 1.18 or later
9090
* Properly configured `go.mod` file for the code under test
9191
* GCC and `github.com/stretchr/testify/assert` installed
@@ -113,15 +113,18 @@ java -jar utbot-cli-2022.8-beta.jar runGo --help
113113
`generateGo` options:
114114

115115
* `-s, --source TEXT`, _required_: specifies a Go source file to generate tests for.
116-
* `-f, --function TEXT`, _required_: specifies a function name to generate tests for. Can be used multiple times to select multiple
117-
functions.
118-
* `-go, --go-path TEXT`, _required_: specifies a path to a Go executable. For example, `/usr/local/go/bin/go`.
116+
* `-f, --function TEXT`: specifies a function name to generate tests for. Can be used multiple times to select multiple functions.
117+
* `-m, --method TEXT`: specifies a method name to generate tests for. Can be used multiple times to select multiple methods.
118+
* `-go TEXT`, _required_: specifies a path to a Go executable. For example, `/usr/local/go/bin/go`.
119+
* `-gopath TEXT`, _required_: specifies a path to your workspace location. It defaults to a directory named `go` in your home directory: `$HOME/go` for Unix, `$home/go` for Plan 9, and `%USERPROFILE%\go` (usually `C:\Users\YourName\go`) for Windows.
120+
* `-parallel INT`: specifies the number of fuzzing processes running at once (eight by default).
119121
* `-et, --each-execution-timeout INT`: specifies a timeout in milliseconds for each target function execution.
120122
The default timeout is 1,000 ms.
121123
* `-at, --all-execution-timeout INT`: specifies a timeout in milliseconds for all target function executions.
122124
The default timeout is 60,000 ms.
123125
* `-p, --print-test`: specifies whether a test should be printed out to `StdOut`. Disabled by default.
124126
* `-w, --overwrite`: specifies whether to overwrite the output test file if it already exists. Disabled by default.
127+
* `-fm, --fuzzing-mode`: stops test generation when a `panic` situation, an error, or timeout occurs (only one test will be generated for one of these cases).
125128
* `-h, --help`: shows a help message and exits.
126129

127130
`runGo` options:

utbot-go/docs/DEVELOPER_GUIDE.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,45 @@ flowchart TB
99
A["Target selection and configuration (IntelliJ IDEA plugin or CLI)"]:::someclass --> B(Go source code analysis)
1010
classDef someclass fill:#b810
1111
12-
B --> C(Fuzzing)
13-
C --> D(Executing functions)
14-
D --> E(Getting results)
15-
E --> C
16-
C ---> F(Test file generation)
12+
B --> C(Code instrumentation)
13+
C --> D(Generation of arguments)
14+
D --> E(Executing functions)
15+
E --> F(Getting results)
16+
F --> D
17+
D ---> G(Test file generation)
1718
```
1819

1920
### Target selection and configuration
2021

2122
A user manually selects the target source file and functions to generate the tests for.
2223
Test generation settings are also configured manually.
2324

25+
### Code instrumentation
26+
27+
After each line in a function, UnitTestBot Go adds logging about this line traversal during the execution.
28+
2429
### Go source code analysis
2530

26-
UnitTestBot Go collects information about the target functions:
27-
* signatures and type information (in the basic version);
28-
* constants in the function bodies (to be implemented).
31+
UnitTestBot Go gains information about the `int` or `uint` value size in bits, and information about the target functions:
32+
* signatures and type information;
33+
* constants in the function bodies.
2934

3035
As a result, UnitTestBot Go gets an internal
3136
representation of the target functions.
3237

33-
### Fuzzing
38+
### Generation of arguments
3439

35-
During the fuzzing stage, UnitTestBot Go generates the input values for the source code.
40+
At this stage, UnitTestBot Go generates the input values for the target functions.
3641

3742
### Executing target functions
3843

39-
UnitTestBot Go executes the target functions with the generated values as arguments and analyses the result
40-
to continue or stop the generation process.
44+
UnitTestBot Go executes the target functions with the generated values as arguments.
4145

4246
### Getting results
4347

4448
The result of target function execution is sent to the fuzzer for analysis:
4549
coverage rate information guides the following value generation process.
46-
Based on this feedback,
50+
Based on remaining time,
4751
the fuzzer decides whether it should continue or stop generating input values.
4852

4953
### Test code generation

0 commit comments

Comments
 (0)