Assertions and Unit Testing
Python
Full documentation - https://docs.python.org/3/library/unittest.html
Why use assertListEqual()
instead of just assertEqual()
? Well, they are designed to show the difference between the two values on failure. So students will receive more accurate feedback if you use the proper assertion.
Feedback:
You can add feedback to assertion failures to alert students what they might have done wrong. To do so, just simply add an additional argument as a string containing the message you want to display.
Useful Links:
Skipping test and expected failures: https://docs.python.org/3/library/unittest.html#skipping-tests-and-expected-failures
Java
Full documentation - https://junit.org/junit4/javadoc/4.12/org/junit/Assert.html
Feedback:
You can add feedback to assertion failures to alert students what they might have done wrong. To do so, just simply add a string containing the message you want to display as the first argument in the method call.
Ruby
Ruby calls assertions "matchers"
Full documentation - https://rspec.info/documentation/3.9/rspec-expectations/RSpec/Matchers.html
Last updated