There are three types of tests in Go.
- Basic Tests (Regular tests)
- Benchmark Tests
Benchmark test are for identify performance with related to limits. These tests required to have Benchmark prefix in functions.
- Example Tests
In this post, we will create a Basic test. We are going to do Test Driven Development, therefore we need to first write test functions.
Then write the actual code.
Now using following command we can run test runner. The output will be like below.
Next will change result comparing value for demonstration purpose. Then our test function become incorrect.
Run go test command again. Then output is like below.
No comments:
Post a Comment