notexOPENOverview
Notex/Languages/Practice: Basic Testing
05.17LESSON 17 OF 29 · 1 MIN READ

Practice: Basic Testing

Always free to read

These exercises help you practice the basics of Go testing.

  1. In the ex1 directory, there is a file called calculator.go, with a function called Average. Create a calculator_test.go file with a function to test Average. If you find a bug in the function, fix the bug and confirm that the test passes.

  2. In the ex2 directory, there is a file called temperature.go with a function called Convert. Create a temperature_test.go file with a function that uses a table test to validate all inputs and possible errors. If you find a bug in the function, fix the bug and confirm that the test passes.

  3. In the ex3 directory, there is a file called counter.go with a function called TotalFile. Create a counter_test.go file with a function to test TotalFile. Use a helper function to create both good and bad sample data.

Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K