nim-wiki/Testing.asciidoc

27 lines
943 B
Plaintext
Raw Normal View History

2015-04-22 12:57:33 +00:00
### General testing tips
Define a "testing" conditional symbol at compile time: nim --define:testing main.nim
``` Nim
when defined(testing):
# testing-related code
else:
# production code
```
### Unit testing
2015-04-22 12:58:34 +00:00
Use http://nim-lang.org/unittest.html[unittest]
2015-04-22 12:57:33 +00:00
2015-06-28 12:34:29 +00:00
Write your unit test first. Write all of them first! They should fail 100%. Then write your codes. If your codes are correct then when you run your unit tests again they should all pass 100%. If your unit tests do not pass 100% but only pass like 25% then you have error in your codes! Fix your codes and run your unit tests again. Keep fixing codes until the unit tests are 100%. You can remember it by the thinking of : RED :red_circle:, REFACTOR :factory:, GREEN :green_heart:! Go for the green!
2015-04-22 12:57:33 +00:00
### Functional and integration testing
2015-04-22 12:58:34 +00:00
TODO
2015-04-22 12:57:33 +00:00
### Code coverage
2015-06-28 12:29:42 +00:00
Try to test every path of execution in your softwares. That is the key to maximizing your code coverages.
2015-04-22 12:58:34 +00:00
TODO