简体   繁体   中英

javascript unit testing : how do you keep track of all the tests you have written and what code coverage you have?

I'm writing up unit tests for a app but I'm having difficulty keeping track of what scenarios I've tested for in each method.

I'm currently using qunit and creating a testing directory for each object that I'm unit testing and a single file for each method I'm testing but how do you get a good overview of all your tests in an easy to digest form?

Ideally I'd like to have something

  • which could take my unit tests and add the test description next to the function which it relates to in the code itself so when in the code I can see the tests I've got for the method straight away
  • have some sort of easy to read overview of all my tests

Does anyone have any recommendations of tools or practices which may help out with this problem?

The projects I've worked on have all been Server+Client projects, where we had a suite of unit tests for our server side code, and wanted to integrate our client side unit tests into that process.

In that case, I have written a "Unit Test" in my server side code that opened up each QUnit test in a browser, then scraped the DOM for success/failure entries, and called Assert(false, text_scraped_from_dom). Then all of my qUint tests were run as part of my CI build and showed up as failing tests there.

I have done this for Java with httpunit, and for .NET with watin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM