Skip to content

Commit

Permalink
Document contributing tests to Godot's C++ codebase
Browse files Browse the repository at this point in the history
This partially addresses
godotengine/godot-proposals#1586.
  • Loading branch information
Calinou committed Sep 30, 2020
1 parent 3c441ba commit 8a84b3c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ If your pull request modifies parts of the code in a non-obvious way, make sure
to add comments in the code as well. This helps other people understand the
change without having to look at `git blame`.

### Write unit tests

When fixing a bug or contributing a new feature, we recommend including unit
tests in the same commit as the rest of the pull request. Unit tests are pieces
of code that compare the output to a predetermined *expected result* to detect
regressions. Tests are compiled and run on GitHub Actions for every commit and
pull request.

Pull requests that include tests are more likely to be merged, since we can have
greater confidence in them not being the target of regressions in the future.

For bugs, the unit tests should cover the functionality that was previously
broken. If done well, this ensures regressions won't appear in the future
again. For new features, the unit tests should cover the newly added
functionality, testing both the "success" and "expected failure" cases if
applicable.

Feel free to contribute standalone pull requests to add new tests or improve
existing tests as well.

See [Unit testing](https://docs.godotengine.org/en/latest/development/cpp/unit_testing.html)
for information on writing tests in Godot's C++ codebase.

### Be nice to the Git history

Try to make simple PRs that handle one specific topic. Just like for reporting
Expand Down

1 comment on commit 8a84b3c

@CitrusWire
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those who are new to the concept of Unit Testing, might it be worth referencing a tutorial on good test writing principles?
This one seems decent:
https://medium.com/better-programming/13-tips-for-writing-useful-unit-tests-ca20706b5368

And/or alternatively it may be worth linking to something like that on the Godot unit_testing.html page.

Please sign in to comment.