TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Visual Studio Unit Test Integration

Open chriscamicas opened this issue 11 years ago • 13 comments

Could you please provide a unit test platform integrated within Visual Studio Test Explorer and of course TFS builds.

I know about Chutzpah extension, but :

  • it doesn't integrate well with VS
  • it's very slow (iterating over the entire solution content)
  • it doesn't follow the new tools for front/web dev (eg TaskRunnerExplorer)

I also know about Javascript Unit Test framework (QUnit, Jasmine), but they don't integrate with VS either.

Thanks

chriscamicas avatar Dec 08 '14 17:12 chriscamicas

@chriscamicas, have you tried NTVS? It is an excellent resource.

import assert = require('assert');

export function myTest() {
    assert.ok(true, "This shouldn't fail");
}

NoelAbrahams avatar Dec 08 '14 18:12 NoelAbrahams

Definitely heard this before, surprised we didn't already have something logged for it. Edited the title for clarity.

danquirk avatar Dec 08 '14 20:12 danquirk

@NoelAbrahams thanks for the link, seems a nice extension. I'll try it. @danquirk thanks

chriscamicas avatar Dec 09 '14 08:12 chriscamicas

@NoelAbrahams I just took a look at NTVS, it's a really great plugin, wonderful integration with VS. But, in order to run the tests, it seems you need to create a specific NodeJS project.

In my case, I have a classic Asp.Net project (csproj) with TypeScript files inside... I can't use NTVS in this project (can't add unit test files). I should probably split my project in 2, one for the backend (keep Asp.Net), another for the front : move to NodeJS project to use this great tooling, but it lacks build mechanism for the front (gulp tasks in my case).

Anyway, TypeScript unit tests should be available in every project containing a TS file. This issue/suggestion would be a really great improvement.

chriscamicas avatar Dec 09 '14 09:12 chriscamicas

@chriscamicas, it's probably good practice to keep your source and tests separate. NTVS, as the name implies, is primarily for writing server-side TypeScript (or JavaScript) and tests.

For client (browser) code, the best option at present is QUnit or similar (which as you say don't integrate with VS). I'm not really sure that I want browser testing to be integrated in Visual Studio; that sounds rather messy. I believe Chutzpah attempts to do that, but not very well as you state above.

NoelAbrahams avatar Dec 09 '14 09:12 NoelAbrahams

@chrisbubernak I've found Chutzpah pretty strong inside VS for my own purposes - for what it's worth I'm writing Jasmine tests and I've found it performant enough. Though I am helping it along with a chutzpah.json file so maybe that's why. If you're curious you can see an example of how this works here

@NoelAbrahams - intrigued by your comment. Are you using a some kind of grunt / gulp filewatcher along with NTVS to do the running? Don't know if you've got an example you could point to?

johnnyreilly avatar Dec 09 '14 09:12 johnnyreilly

@johnnyreilly, I haven't used Chutzpah, so you may be right there.

Are you using a some kind of grunt / gulp filewatcher along with NTVS to do the running?

Do you mean for running the tests? The tests just show up on Test Exporer and they can be run from there.

image

NoelAbrahams avatar Dec 09 '14 10:12 NoelAbrahams

Yes I did mean running the tests (Chutzpah similarly drops them into Test Explorer). I think I'll investigate NTVS further...

johnnyreilly avatar Dec 09 '14 10:12 johnnyreilly

Don't know if you've got an example you could point to?

The steps are:

  1. Install NTVS.

  2. Create an NTVS project. A "Blank Node.js Web Application". (They should be found under TypeScript).

  3. Add a new file of type "TypeScript UnitTest file".

  4. Add the test case

    import assert = require('assert');
    
    export function myTest() {
    assert.ok(true, "This shouldn't fail");
    }
    

    NB: You will need to import your SUT from where you have it defined.

  5. Build the project.

  6. Open up Test Explorer and the test myTest should show up.

NTVS does the file system watching etc. and updates the test explorer when changes are made.

NoelAbrahams avatar Dec 09 '14 10:12 NoelAbrahams

Sweet!

johnnyreilly avatar Dec 09 '14 10:12 johnnyreilly

FYI - NodeJS developers had forked the source code into io.js as of last Tuesday (Dec 2nd, 2014) due to their frustrations with "manager" 's iron grip control over source code in GitHub. The "manager" wouldn't accept their bug fixes and coding improvement, so their frustration had boiled over.

I do not know if NTVS will stick to NodeJS or io.js down the road.

Just giving you head up. ;-)

fletchsod-developer avatar Dec 09 '14 14:12 fletchsod-developer

This is out of scope of this repo. We would love to see this end-to-end integration happening though. The TypeScript core team does not have resources to address all such requests. We would be happy to work with any interested parties to facilitate the solution in any way possible, but I do not think we can take on such feature at the time being.

mhegazy avatar Dec 08 '15 23:12 mhegazy

@NoelAbrahams thank's for the link to NTVS and explanation :+1:

resnyanskiy avatar Jan 16 '16 07:01 resnyanskiy