How to specify that a method should fail for a particular input?

12 views
Skip to first unread message

Jakub Holý

unread,
May 13, 2019, 5:19:10 AM5/13/19
to concordion
Hello!

I want to specify a business rule that requires that processing fails if the input is invalid. How do I specify that it is expected to fail? The only solution I can think of is to return a boolean indicating success/failure and checking that. Is this what people typically do? Since there is no `expectToFail` / `expectToFailWithMessageContaining` Something like?

### Examples

If the employee Adam is in the known department [HR](- "#dept") then salary report generation should
[succeed](- "c:assert-true=salaryReportForEmployeeInDept(#dept)")

If the employee Bob is in an unknown department [Unknown](- "#dept") then salary report generation should
[fail](- "c:assert-false=salaryReportForEmployeeInDept(#dept)")

Thank you!

Jimmy Kemp

unread,
May 13, 2019, 5:28:53 PM5/13/19
to concordion
Hi Jakub

Yes, that's what I would do.  Though perhaps I might modify as below ....

e.g. 
Given Adam is an employee in the [HR](- "#dept") department  
Then salary report generation is [allowed](- "c:assertTrue=salaryReportForEmployeeInDept(#dept)") 


Given Bob is an employee in the [Unknown](- "#dept") department  
Then salary report generation is not [allowed](- "c:assertFalse=salaryReportForEmployeeInDept(#dept)") 


Also, fyi in case you haven't spotted them, and you might subsequently find them useful!

Cubano ( part of the Concordion family) - is a packaged framework for implementing web and API test suites. Builds on Concordion to bring your software delivery team together around living documentation.
Cubano also contains the concordion-status-info-extension, which provides an ExpectedToFail status, though in this case is because the feature is failing (e.g. incomplete code, bug etc), as opposed to your BR scenario.

cheers,
JImmy

Nigel Charman

unread,
May 19, 2019, 7:38:45 AM5/19/19
to conco...@googlegroups.com
Dependent on the audience for the spec, I'd go a step further and have the method return a String - for example "run successfully" or "fail with error 'Unknown Employee'".

If the employee Adam is in the known department [HR](- "#dept") then salary report generation should
[run successfully](- "c:assert-equals=salaryReportForEmployeeInDept(#dept)")

If the employee Bob is in an unknown department [Unknown](- "#dept") then salary report generation should 
[fail with error 'Unknown Employee'](- "c:assert-equals=salaryReportForEmployeeInDept(#dept)") 

This technique is documented at https://concordion.org/instrumenting/java/markdown/#assert-true-and-assert-false-commands.

cheers
Nigel
--
You received this message because you are subscribed to the Google Groups "concordion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concordion+...@googlegroups.com.
To post to this group, send email to conco...@googlegroups.com.
Visit this group at https://groups.google.com/group/concordion.
To view this discussion on the web, visit https://groups.google.com/d/msgid/concordion/f32777df-fc66-4ed2-b7f0-a49acadc4347%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages