Update unit-test guidelines to require independent testing
See original GitHub issueSubject of the documentation
Now we have some tests where we test different cases sequentially inside one single function. This is not ideal as sometimes previous tests might have an unexpected impact on the following tests.
Imagine we test a function named func
we can build tests as follows:
class TestFunc:
def test_case1(self):
...
def test_case2(self):
...
so that case1 and case2 are isolated.
In case we are just changing the values of the arguments, we can use Parametrizing tests to remove redundant code.
We do not have to refactor all existing code, but we should update the guidelines so that new tests or modified tests should be refactored.
If the documentation request is approved, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)
Yes
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Unit Tests, How to Write Testable Code, and Why It Matters
Essentially, a unit test is a method that instantiates a small portion of our application and verifies its behavior independently from other parts....
Read more >Unit Testing Best Practices: 9 Ways to Make Unit Tests Shine
6. Avoid Test Interdependence ... Unit testing does not require 100% test coverage. You should set up fewer, but high-quality unit tests than...
Read more >A Deep Dive into Unit Testing - Semaphore CI
Each unit test has to follow a set of defined requirements. Take a look at the list below: Classes should not break the...
Read more >Unit Testing Guidelines What to Test And What Not
Find guidelines regarding unit testing- what to be unit tested or not, to what extent and so on.
Read more >unittest — Unit testing framework — Python 3.11.1 ...
Skipping a test is simply a matter of using the skip() decorator or one of its conditional variants, calling TestCase.skipTest() within a setUp()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@s-sd I’ve updated the issue content, does it make more sense now?
@mathpluscode I can work on DeepReg tickets after 28th Sept, MRes dissertation submission. Happy to work on it after then!