Created
February 9, 2016 12:18
-
-
Save apoorvam/ef5f75e95f416fcb0495 to your computer and use it in GitHub Desktop.
Table Driven Execution in Gauge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ gauge specs/Simple\ Interest.spec | |
| # Simple Interest | |
| |principal|tenure|roi|interest| | |
| |---------|------|---|--------| | |
| |10000 |4 |8 |3200 | | |
| ## Compute Simple Interest ✔ | |
| |principal|tenure|roi|interest| | |
| |---------|------|---|--------| | |
| |0 |4 |5 |0 | | |
| ## Compute Simple Interest ✔ | |
| |principal|tenure|roi|interest| | |
| |---------|------|---|--------| | |
| |1000 |4 |8 |320 | | |
| ## Compute Simple Interest ✔ | |
| Successfully generated html-report to => ./reports/html-report | |
| Specifications: 1 executed 1 passed 0 failed 0 skipped | |
| Scenarios: 1 executed 1 passed 0 failed 0 skipped | |
| Total time taken: 17ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Simple Interest | |
| =============== | |
| This is an executable specification file which follows markdown syntax. | |
| Every heading in this file denotes a scenario. Every bulleted point denotes a step. | |
| |principal|tenure|roi|interest| | |
| |---------|------|---|--------| | |
| |10000 |4 |8 |3200 | | |
| |0 |4 |5 |0 | | |
| |1000 |4 |8 |320 | | |
| Compute Simple Interest | |
| ----------------------- | |
| * Simple Interest for principal <principal> tenure <tenure> and roi <roi> is <interest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.thoughtworks.gauge.Step; | |
| import static org.junit.Assert.assertEquals; | |
| public class SimpleInterest { | |
| private int principal; | |
| private int tenure; | |
| private int roi; | |
| @Step("Simple Interest for principal <principal> tenure <tenure> and roi <roi> is <interest>") | |
| public void computeSI(int principal, int tenure, int roi, int interest) { | |
| this.principal = principal; | |
| this.tenure = tenure; | |
| this.roi = roi; | |
| int obtained = computeInterest(); | |
| assertEquals("Obtained SI doesn't match expected amount.", interest, obtained); | |
| } | |
| private int computeInterest() { | |
| return (principal * tenure * roi)/ 100; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment