Merge pull request #61 from dickeyxxx/readme-syntax

allow github syntax highlighting
This commit is contained in:
Tyler 2014-07-01 09:47:21 -06:00
commit 8e57a8565a

View File

@ -31,6 +31,7 @@ The `assert` package provides some helpful methods that allow you to write bette
See it in action:
```go
func TestSomething(t *testing.T) {
// assert equality
@ -52,12 +53,14 @@ See it in action:
}
}
```
* Every assert func takes the `testing.T` object as the first argument. This is how it writes the errors out through the normal `go test` capabilities.
* Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions.
if you assert many times, use the below:
```go
func TestSomething(t *testing.T) {
assert := assert.New(t)
@ -78,6 +81,7 @@ if you assert many times, use the below:
assert.Equal("Something", object.Value)
}
}
```
`http` package
--------------
@ -91,6 +95,7 @@ The `mock` package provides a mechanism for easily writing mock objects that can
An example test function that tests a piece of code that relies on an external object `testObj`, can setup expectations (testify) and assert that they indeed happened:
```go
package yours
import (
@ -143,6 +148,7 @@ An example test function that tests a piece of code that relies on an external o
testObj.Mock.AssertExpectations(t)
}
```
For more information on how to write mock code, check out the [API documentation for the `mock` package](http://godoc.org/github.com/stretchr/testify/mock).
@ -153,6 +159,7 @@ The `suite` package provides functionality that you might be used to from more c
An example suite is shown below:
```go
// Basic imports
import (
"testing"
@ -185,6 +192,7 @@ An example suite is shown below:
func TestExampleTestSuite(t *testing.T) {
suite.Run(t, new(ExampleTestSuite))
}
```
For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go)
@ -192,6 +200,7 @@ For more information on writing suites, check out the [API documentation for the
`Suite` object has assertion methods:
```go
// Basic imports
import (
"testing"
@ -222,6 +231,7 @@ For more information on writing suites, check out the [API documentation for the
func TestExampleTestSuite(t *testing.T) {
suite.Run(t, new(ExampleTestSuite))
}
```
------
@ -240,6 +250,7 @@ This will then make the following packages available to you:
Import the `testify/assert` package into your code using this template:
```go
package yours
import (
@ -252,6 +263,7 @@ Import the `testify/assert` package into your code using this template:
assert.True(t, true, "True is true!")
}
```
------