forked from runatlantis/atlantis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contributing.md with testing guidelines (runatlantis#65)
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Testing | ||
* place tests under `{package under test}_test` to enforce testing the external interfaces | ||
* if you need to test internally i.e. access non-exported stuff, call the file `{file under test}_internal_test.go` | ||
* use `testing_util` for easier-to-read assertions: `import . "github.com/hootsuite/atlantis/testing_util"` | ||
* don't try to describe the whole test by its function name. Instead use `t.Log` statements: | ||
```go | ||
// don't do this | ||
func TestLockingWhenThereIsAnExistingLockForNewEnv(t *testing.T) { | ||
... | ||
|
||
// do this | ||
func TestLockingExisting(t *testing.T) { | ||
t.Log("if there is an existing lock, lock should...") | ||
... | ||
t.Log("...succeed if the new project has a different path") { | ||
// optionally wrap in a block so it's easier to read | ||
} | ||
``` | ||
* each test should have a `t.Log` that describes what the current state is and what should happen (like a behavioural test) |