Skip to content

Commit

Permalink
hello-world: add more detailed explanation concerning the test consis…
Browse files Browse the repository at this point in the history
…tency setup (#532)

Closes #515
  • Loading branch information
tleen authored Feb 20, 2017
1 parent 62b2f42 commit fe41836
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions exercises/hello-world/hello_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ import "testing"
// In other words, define a function with the following signature:
// HelloWorld() string
//
// Also define a testVersion with a value that matches
// the targetTestVersion here.

// In any exercise solution using the following tests you must also define a
// "testVersion" constant with a value that matches the targetTestVersion
// here. See how it is done in the the ./hello_world.go file provided.
// This is a common convention for ensuring test consistency throughout the
// Exercism Go language track.
//
// See TestTestVersion function below for how this and the testVersion
// constants are used.
const targetTestVersion = 4

// TestTestVersion is used to ensure the exercise solution is considered
// compatible with the rest of the tests. It should be the initial testing
// function in any test suite. If there is an incompatibility the tests can
// be considered unreliable therefore this function will abort the testing.
func TestTestVersion(t *testing.T) {
if testVersion != targetTestVersion {
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
Expand Down
10 changes: 10 additions & 0 deletions exercises/hello-world/hello_world.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ package greeting
// after you have posted this code to the Exercism site -- reviewers
// will see that your code can't necessarily be expected to pass the
// current test suite because it was written to an earlier test version.
//
// This is a convention done for Exercism exercises in the Go language track,
// it is not a requirement of the Go programming language.
//
// This test versioning setup will be common to all the exercises in the
// Go language track. When crafting your own solution file from scratch you
// will be expected to add this constant or the initial test will fail.
// The version number you should use will be found in the constant
// "targetTestVersion" in the test file, see ./hello_test.go for more
// information.
const testVersion = 4

// HelloWorld needs a comment documenting it as package does.
Expand Down

0 comments on commit fe41836

Please sign in to comment.