mercredi 21 janvier 2015

Skip cucumber tests without reporting

I have the following cucumber scenario:



Scenario: Display of Dual Rates during rate change period
Given this is a rate change period
When I ask for a price for Basic Extras product on Extras Product page
Then I see current and new rates on Join Step 1
And I see current and new rates on sticky header


Our prices change each year roughly, and for a couple of months there's an offer to buy at the current price, warning that prices go up at the end of the rate change period.


Now, our current rate change period is slated to finish in 6 weeks time. After that, the above scenario doesn't apply for another year and the test should be skipped without comment and not appear in any reports. Other tests will check the single rate usually displayed on the website. Basically, this test should be ignored without comment.


What's the best way to represent this in cucumber? The options appear to be:




  • Use a cucumber tag like @ratechange. Downside: Cucumber generally helps us avoid this kind of coding, preferring plain English. It violates DRY because the BDD is clear that this is a rate change situation, and the tag duplicates that




  • Mark as an expected failure outside of rate-change period. Downside: this isn't a fail, the test is just not relevant




  • use code-behind and have each of the steps check this is a rate-change period. There are three problems:




    1. the step When I ask for a price for Basic Extras product on Extras Product page is not rate-change specific and can work in or out of a rate-change period. But if the test code recognises that we are not in a rate change period it should not run




    2. the other steps need to repeat checking code, which violates DRY (Don't Repeat Yourself) along the lines of (Groovy)




    3. the test is reported as passing, which is not accurate. It should not be reported at all






My ideal would be to cancel the test programmatically at step 1 and wipe it from any reporting.


Comments?


Aucun commentaire:

Enregistrer un commentaire