Advice needed on correction of ineffective tests – how should PR demonstrate that test are ineffective? #20671
Unanswered
codeandclay
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Trying to understand
counter_culture
, I realised some tests incredit_spec
are ineffective. I can introduce a breaking change inmodels/credit.rb
but the tests still pass.If I was fixing a bug in the code, I would add a regression test to my PR. But I'm doing the converse, I'm fixing the test. To prove it's broken, I need to break the code.
I feel I should add something in the PR that proves the tests are ineffective but I need some guidance.
Should I introduce the bug in the PR with the fixed test, followed by a commit reverting the breakage? Or is that unwise? Is the fixed test sufficient on its own?
I've pushed a WIP branch to GH as an example. Help would be appreciated!
Introduce change that should cause credit_spec to fail
This is a breaking change. The credits counter is no longer populated yet the
specs pass.
These tests should fail:
#credits_count counts credits for organization
#credits_count counts credits for user
Instead of comparing the column value with the expected credit count, the
tests are comparing zero.
Ensure credit_spec fails
For the tests to fail as expected, the user and organisation test subjects
need to be created after their related credits. To ensure this, I have used
the eager loading
let!
.Undo breaking change in code
Now that the tests fail, we can see that they pass after undoing the breaking
change.
Beta Was this translation helpful? Give feedback.
All reactions