Skip to content

Commit

Permalink
Merge pull request #5033 from Prateek93a/update-unit-testing-doc
Browse files Browse the repository at this point in the history
Update unit_testing.md
  • Loading branch information
montoyamoraga committed Feb 3, 2021
2 parents 396907d + a8abe64 commit a765b36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contributor_docs/unit_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ If you have to add a test file for a module to `test/unit`, then you'll also nee

### Writing Unit Tests

Pick a unit, it can be a method or a variable to test. Lets use `p5.prototype.isKeyPressed` as an example. Before beginning to write tests, we need to understand the expected behaviour of this method.
Pick a unit, it can be a method or a variable to test. Lets use `p5.prototype.keyIsPressed` as an example. Before beginning to write tests, we need to understand the expected behaviour of this method.
**Expected behaviour:** The boolean system variable should be true if any key is pressed and false if no keys are pressed.
Now you can think of various tests against this expected behaviour. Possible test cases could be:

Expand All @@ -89,7 +89,7 @@ Now you can think of various tests against this expected behaviour. Possible tes
- it should be false if no keys are pressed
- if you can think of more, go ahead and add tests for them!

We can create a test suite for `p5.prototype.isKeyPressed` and start creating tests for it. We will use mocha for structuring our unit tests.
We can create a test suite for `p5.prototype.keyIsPressed` and start creating tests for it. We will use mocha for structuring our unit tests.

```
suite('p5.prototype.keyIsPressed', function() {
Expand Down

0 comments on commit a765b36

Please sign in to comment.