Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wish: AssertNotImplemented() should return True #13

Open
RickBorup opened this issue Mar 20, 2018 · 5 comments
Open

Wish: AssertNotImplemented() should return True #13

RickBorup opened this issue Mar 20, 2018 · 5 comments

Comments

@RickBorup
Copy link

AssertNotImplemented() should return True, not False. Here's why:

Reason 1 (tautological): If a test is not implemented, then by definition it's always true that it is not implemented.

Reason 2 (practical): By returning False, AssertNotImplemented() trains us to ignore failing tests.

The general rule of unit testing is that all test results must be green before code is committed or shipped ("all green or no go").

When tests that are not implemented return False, we train ourselves to ignore those red results because we know they're expected. This is a problem because if we get used to seeing and ignoring any red results, even if only those from tests that are not implemented, we might miss a red result from a newly failing test that is implemented.

This can be particularly problematic in larger test suites.

Example: A test suite has 100 tests. The 76 that are implemented return True (green). The 24 that are not implemented are there as placeholders for future tests, and they return False (red). We become accustomed to seeing and ignoring the 24 red rows every time we run the whole test suite. If we then modify or refactor a method and its test subsequently fails, we might not notice there are now 25 failing tests instead of only 24. We might go ahead and commit or ship the code even though not all test results are green, and if we do that we have just released a bug.

On the other hand, if tests that are not implemented return True (green), we know all red results require action and we know we can't commit and ship the code until all tests are green.

@eselje
Copy link
Collaborator

eselje commented Mar 21, 2018 via email

@RickBorup
Copy link
Author

Good suggestion. I'd be OK with a third color, maybe orange to signify 'attention needed' rather than a 'stop' condition like red.

@eselje
Copy link
Collaborator

eselje commented Mar 21, 2018 via email

@RickBorup
Copy link
Author

/stoplight theme/ That's what I was thinking, too. Yellow would be good for not-implemented.

@cwollenhaupt
Copy link
Contributor

If a test shouldn't run, because it's not done yet, you should mark the test procedure as "HIDDEN" and FoxUnit won't attempt to execute it. Once you start working on a test case remove the "HIDDEN" keyword to mark the test as active. HIDDEN is equivalent to the "Ignore" attribute you can assign to a test in other languages.

Unit tests are really a binary thing. They pass or they fail, there's no try, to quote Yoda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants