Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a better way to group and describe tests #7

Open
phidias opened this issue Jun 9, 2016 · 4 comments
Open

Find a better way to group and describe tests #7

phidias opened this issue Jun 9, 2016 · 4 comments
Milestone

Comments

@phidias
Copy link

phidias commented Jun 9, 2016

Hi there,

Is it possible to add a description to a test? Cause I ended up adding the description into the test's name and it's hard to read it when I use chaplain interactively.

Here is what I ended up doing:

`
suite('drinks', function () {

config(configuration);

test('get_drinks', {url: '/api/drinks/get_drinks?venueId=56b1eb441ea853d7b891f600'});
test('get_drinks__without_venue_id', {url: '/api/drinks/get_drinks'});
test('get_drinks__with_invalid_venue_id', {url: '/api/drinks/get_drinks?venueId=56b1eb441ea853d7b891f6bb'});

});`

Here is what I would like to be doing:

`
suite('drinks', function () {

config(configuration);

test('get_drinks', {url: '/api/drinks/get_drinks?venueId=56b1eb441ea853d7b891f600'});
test('get_drinks', 'venueId url param is missing', {url: '/api/drinks/get_drinks'});
test('get_drinks', 'no such venueId in db', {url: '/api/drinks/get_drinks?venueId=56b1eb441ea853d7b891f6bb'});

});
`

or it could be (optionally) written more explicitly like this:

test({ name: 'get_drinks', description: 'venueId url param is missing', request: {url: '/api/drinks/get_drinks'} });

What is your view on it? Is there another way of doing that? Hm .. now that I'm thinking about it I didn't try adding the description into the test name .. oh .. it seems to be working .. ok cool! I can do with that.

Sorry for posting this .. I thought that since I wrote it up to here then it might be good for you to know that I faced this issue. Feel free to mark it as resolved.

@krajzeg
Copy link
Owner

krajzeg commented Jun 9, 2016

Will think this through. For now, there is a test name just so you have some place to put a description in. For the future, maybe it will make more sense to provide mocha-like contexts for those things, e.g.:

context('/api/drinks', ()=>{
  test('when drink found', {...})
  test('when there is no such drink', {...})
  test('when there is no such venue', {...})
  test('when venue does not serve this drink', {...}) 
})

Food for thought. Keeping this open for discussion and more thoughts on the subject - I'm basically open to the idea that the current system might not be the best for what Chaplain wants to do.

@phidias
Copy link
Author

phidias commented Jun 10, 2016

Cool .. I like this syntax. Will serve well for grouping the tests for each endpoint.

@krajzeg krajzeg changed the title Test description Find a better way to group and describe tests Jun 10, 2016
@krajzeg
Copy link
Owner

krajzeg commented Jun 10, 2016

So, I put some thought into it, and this is definitely something that I'd like to do before 0.4.0 (the "public" release when I start yelling loudly to people about chaplain ;)).
Letting you group the tests (probably by endpoint, but whatever you want) will come in handy for the "sequential" tests coming in 0.5.0 too, and will give people a place to provide shared configuration for a group of tests (like a common header to be sent for all tests).

@krajzeg krajzeg added this to the 0.4.0 milestone Jun 10, 2016
@phidias
Copy link
Author

phidias commented Jun 10, 2016

Shared config sounds like a good idea as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants