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

Ability to tag tests #127

Closed
wants to merge 2 commits into from
Closed

Ability to tag tests #127

wants to merge 2 commits into from

Conversation

bnoguchi
Copy link

@bnoguchi bnoguchi commented Sep 1, 2011

The proposed feature is the ability to append @tags to the end of single tests and then to leverage these tags to filter tests in a more powerful way from the command line.

Example:

module.exports = {
    'should crawl the entire internet @slow @crawler': function () {},

    'should assert ok @fast @simple': function () { assert.ok(true); }
}

$ expresso --tags slow runs only the first test
$ expresso -T fast runs only the second test
$ expresso -T "slow || fast" runs both tests and demonstrates the use of conditional tag statements
$ expresso -T "fast && simple" runs the second test
$ expresso -T "slow && fast" runs none of the tests

This is generally useful to label slow tests and only partition tests by functionality (not by both functionality and speed, which I had to do in a current project).

This is also useful if one test is failing, and you only want to run that single test without commenting out all the other tests. In this case, you could just tag the target test with @single and run expresso with -T single.

In general, I imagine people would find other uses for this, and I think it's useful enough that I'd love to see it make its way into master.

Tests are included.

--Brian

@tj
Copy link
Member

tj commented Sep 1, 2011

cool i like the idea, i remember felix talking about classifying tests as well. I wonder if it would be better to just separate them via files rather than tags. they might be related conceptually but you could still have http.fast.test.js, http.slow.test.js etc and just set up your makefile to run both or make test-fast etc.

I've actually started rewriting expresso, I can add you to the repo if you want to check it out and we can come up with something in there

@bnoguchi
Copy link
Author

bnoguchi commented Sep 2, 2011

Thanks for the feedback. I've been using the feature.fast.test.js and feature.slow.test.js with an appropriate Makefile for some time. It's just a personal preference to move all related functionality to the same file. But the bigger reason for me is to isolate running a subset of (failing) tests without commenting out a bunch of lines and without having to use the --only command option.

Would love to contribute to the expresso re-write where I can. Definitely add me, and I'd love to take a look. Thanks for the invite.

@tj
Copy link
Member

tj commented Sep 2, 2011

yeah I definitely get what you're going for. I think in some respect in makes sense but at the same time i think just using the separate files is a pretty simple/elegant solution, even if it were to be `./tests/http/{fast,slow}.test.js

@philipmat
Copy link

The make test-fast is a very elegant solution, but if I may add two reasons to go the tag route:

  • would work with tools like autotest, which continuously run your test when the files have changed. With tags you could specify that only @fast tests are to be run.
  • would enable gathering statistics about tests, run time e.g. @slow : 10s, @fast : 0.2s, @api: 2s. This can be achieved with make, but it would require running each label individually, whereas expresso can simply gather it when running: "slow || fast || api"

@tj
Copy link
Member

tj commented Nov 3, 2011

thought of a really simple abstract way to deal with this but it wont be in expresso it'll be in mocha

@tj tj closed this Nov 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants