Last active
March 1, 2018 13:17
-
-
Save basti1302/5051200 to your computer and use it in GitHub Desktop.
An example of a parameterized test suite using the Jasmine BDD framework for JavaScript. This example is in CoffeeScript.
This file contains 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
describe "The suit", -> | |
beforeEach -> | |
console.log('non-parameterized#beforeEach') | |
afterEach -> | |
console.log('non-parameterized#afterEach') | |
it "should execute specs in the non-parameterized part", -> | |
console.log('spec in non-parameterized') | |
expect(true).toBe(true) | |
parameterized = (param) -> | |
describe "The parameterized sub-suit (" + param + ")", -> | |
beforeEach -> | |
console.log('parameterized#beforeEach') | |
afterEach -> | |
console.log('parameterized#afterEach') | |
it "should execute specs in the parameterized part", -> | |
console.log('spec in parameterized') | |
expect(true).toBe(true) | |
it "should be parameterizable", -> | |
console.log('parameter: ' + param) | |
expect(param).toMatch(/[AB]/) | |
parameterized('A') | |
parameterized('B') |
This file contains 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
> jasmine-node spec --coffee --verbose --match "parameterizable.*" | |
non-parameterized#beforeEach | |
spec in non-parameterized | |
non-parameterized#afterEach | |
non-parameterized#beforeEach | |
parameterized#beforeEach | |
spec in parameterized | |
parameterized#afterEach | |
non-parameterized#afterEach | |
non-parameterized#beforeEach | |
parameterized#beforeEach | |
parameter: A | |
parameterized#afterEach | |
non-parameterized#afterEach | |
non-parameterized#beforeEach | |
parameterized#beforeEach | |
spec in parameterized | |
parameterized#afterEach | |
non-parameterized#afterEach | |
non-parameterized#beforeEach | |
parameterized#beforeEach | |
parameter: B | |
parameterized#afterEach | |
non-parameterized#afterEach | |
The suit | |
should execute specs in the non-parameterized part | |
The parameterized sub-suit (A) | |
should execute specs in the parameterized part | |
should be parameterizable | |
The parameterized sub-suit (B) | |
should execute specs in the parameterized part | |
should be parameterizable | |
Finished in 0.022 seconds | |
5 tests, 5 assertions, 0 failures |
Thanks for lazy people the javascript traduction
https://gist.github.com/sinsunsan/cb1779b3b83a33fe8446bf27ef7f6149
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome. I implemented the same in javascript.