We do something similar just using Mocha to test an Express.js API server. I wrote a little overview here: http://51elliot.blogspot.com/2013/08/testing-expressjs-rest-api-with-mocha.html
I had a lot of end-to-end functional tests initially with dependencies between test cases. i.e. test 2 depends on test 1 completing successfully. The dependency problems became apparent pretty quickly. In theory, you should be able to run a single test case from a single test suite, in isolation (using the "grep" command in mocha). Of course this means all the set-up and tear-down needs to be done on a case-by-case basis. For every test step in your sequence, you have to write some before and after scaffolding to set up the preconditions. I made reasonable progress towards test-case independence by putting a collection of setup and tear-down functions in a separate module, and calling them with test data from a json file. Now, for the parts that need to be tested individually, it's possible. With test cases involving stateful operations, it was hard to stub things out fully. I only know of one utility that's capable of stubbing across modules (npm info gently). hope that helps. On Friday, November 15, 2013 5:53:50 AM UTC-5, Alex Kocharin wrote: > > > I want to test an api server, and I have a bunch of scenarios, for example: > "start server with config1" -> "create user1 on server" -> "create object1 > under user1" -> "delete object1" -> "delete user1" -> "shutdown server" > "start server with config1" -> "create user1 on server" -> "create object2 > under user1" -> "delete object2" -> "delete user1" -> "shutdown server" > > With a bunch of asserts after every step. In the example above two > scenarios starts the same, but start to differ later. > > 1) Normally, I want to run whole test suite as fast as possible. So > ideally each step would be executed only once. If I just run all of them > independently, every scenario would launch server itself, and it would be > suboptimal. > 2) In case of errors, I want to run a single scenario independently. If I > just merge all of them manually to one long sequence of tests, I won't be > able to do this. > > So ideally I'm looking for a program that would transform all these > scenarios to one honouring all the dependencies of each step. > > Does something like this exist out there? What should I look for? > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
