https://github.com/elliotchance/dandy
🔬 The handy, dandy test generation tool for Go.
https://github.com/elliotchance/dandy
Last synced: 9 days ago
JSON representation
🔬 The handy, dandy test generation tool for Go.
- Host: GitHub
- URL: https://github.com/elliotchance/dandy
- Owner: elliotchance
- Created: 2015-12-30T06:17:20.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-01T05:10:24.000Z (almost 10 years ago)
- Last Synced: 2025-07-04T20:40:43.141Z (3 months ago)
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Automatically generate tests from your Go source code.
```go
package mainfunc Sign(x int) int {
if x < 0 {
return 1
}
if x > 0 {
return 2
}return 3
}
``````bash
go run dandy.go -- myfile.go
``````go
func TestSignXIsLessThan0(t *testing.T) {
result := Sign(-1)
if result != 1 {
t.Error("Failed")
}
}func TestSignXIsGreaterThan0(t *testing.T) {
result := Sign(1)
if result != 2 {
t.Error("Failed")
}
}func TestSign(t *testing.T) {
result := Sign(0)
if result != 3 {
t.Error("Failed")
}
}
```The tests are rendered from the intermediate JSON format that provides
information on individual paths, steps taken, input and return values:```json
{
"Functions": {
"Sign": {
"Type": "int",
"Args": {
"x": "int"
},
"Paths": {
"": {
"Steps": [
"4: if x \u003c 0 {",
"7: if x \u003e 0 {",
"11: return"
],
"Params": {
"x": 0
},
"Result": 3
},
"XIsGreaterThan0": {
"Steps": [
"4: if x \u003c 0 {",
"7: if x \u003e 0 {",
"8: return"
],
"Params": {
"x": 1
},
"Result": 2
},
"XIsLessThan0": {
"Steps": [
"4: if x \u003c 0 {",
"5: return"
],
"Params": {
"x": -1
},
"Result": 1
}
}
}
}
}
```