How to open Test Runner Tab in IntelliJ? - unit-testing

When i want to execute tests in intelliJ for javascript (Jasmine - karma) I have to open the IntelliJ console and digit the command as in a normal console (grunt karma:tests). I wait, and get all the test result. But in a GUI enviroment, running from command line is not the best. I can do that without need of IntelliJ.
In addition, in one target there are 900 unit tests, when i have to change one UT i have to wait 20 sec. Every time i make a change on one test, i have to run them all.
When an error is present, i have to read the output of the console, that is a nightmare.
That's REALLY very annoying.
In Eclipse it is quite easy to run tests from one page (without need of running all tests of a target), and every test is highlighted in red (failed) or green (passed).
I searched online, and seems that the equivalent for IntelliJ is "Test Runner Tab". I have it installed, i suppose, but... how to display it?
Where to click?
Thanks

Hej, I found the solution thanks to a collegue.
#Morfic: Yes. I searched in many places but the problem was Karma itself. Sometimes it's not difficult to find, but to search...
In short: the installation of karma used by IntelliJ must not be global - for what i understood. But seee the link at the bottom of my answer to have more details.
For me, it was enough to run the following command:
npm uninstall -g karma
I already had installed karma non-globally. Then in the settings of IntelliJ i choose the local installation.
After that, clicking on the "play" green button, the tests started magically, without need of any setting or searching any window.
If I woudn't have the non-global version installed I would need also the following command:
npm install karma --save-dev
More details are in the following:
karma plugin dependencies not being found

Related

How to do Coverage exports for vscode extensions

I have seen a lot of tutorials how to make vscode extensions. Like:
https://code.visualstudio.com/docs/extensions/testing-extensions
And there is many tutorials how to do coverage exports, there many ways how to do it, but I didn't seen good examples which would follow the examples from their docs and work with vscode extensions (they need the extensionHost instead of nodejs).
I have all the tests written in the mocha which is bundled in the vscode as proposed by their documents.
I tried to experiment and I'm stuck, are there any hints or directions where I could continue and get my process working again?
The answer which worked is in the comments to my original question. But to simplify and boil down what had to be done, and what steps I did personally. Not all steps are really essential and required, but these steps made it pretty convient:
installed istanbul, istanbul-coveralls, gulp, gulp-json-editor, coveralls to my package as the DEV dependencies
included the MS supplied istanbul test runner for vscode extension testing into my tests
modified the tests to run an istanbul runner instead of mocha runner directly (the tests itself could stay as they are).
attached reference to the istanbul runner now I had to read the coverconfig.json to know how to do the coverage itself (what parts to ignore, where is source, where to output results, what formats the results should be etc...).
added coverage to gitignore and to vscode project as so they will not annoy me in the UI and will not polute the repo.
added few visual studio launchers/tasks to make it easier for me to trigger them from the UI
installed vscode plugin to display the coverage in the gutters: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters and then added to my project settings the "lcov.path": [ "coverage/lcov.info" ] (or whatever location you will have the line coverage) so the plugin can read and show the coverage directly in the UI.
setup gulp to delete old coverage results and start new ones on each run
added npm scripts for regular tests and for the coverage variant
changed travis steps so the coverage variant is running now instead of the generic non-coverage one. Added script step so the coveralls module is run and broadcasts the results from the coverage/lcov.info to the https://coveralls.io/ website. (i think signing in and doing the first-time setup is required to make it work on their website)
Now on each commit travis will do the work by itself and I can use coveralls banner inside my readme to give quick glipse how well is my coverage. And you can use gulp to watch it for changes and build/test locally and have fast feedback in the UI what lines were covered by your tests.
The setup is similar to the listed links:
https://github.com/Microsoft/vscode-mssql
https://github.com/kenhowardpdx/vscode-gist/pull/10

How do I control autogenerated test targets in WebStorm?

I've just upgraded to WebStorm 2017.1 and suddenly I have these very nice "run this test" buttons in my test files:
However, any time I click one of these buttons, WebStorm is autogenerating a Mocha test target:
The problem is, I'm using Karma for unit tests on this project. I've already followed the instructions from the WebStorm documentation on setting up Karma. I've set up Karma defaults and manually created a Karma target (and removed all Mocha targets, as far as I know), but the IDE still tries to autogenerate a Mocha target any time I ask it to run tests.
How do I tell WebStorm that it should use Karma to run tests, rather than Mocha?
The official answer from JetBrains as of 2017-03-23 is that running individual tests with Karma is not currently supported. This feature request (about 2.5 years old now) is being tracked as WEB-13173.

Get test list in MSTest via Command-Line [duplicate]

I just installed Visual Studio 2013 Premium and was having a good time playing with it and writing unit tests (using MS unit tests). However, the "Test Lists" window and some other Test related windows suddenly disappeared AND they have disappeared from the menu item
Test->Windows. In fact I remember Test->Windows having 4 items under it and now I only see two: Test Explorer, Code Coverage Results. i stress they WERE present in Visual Studio 2013. Clearly, I hit some key combination that made them disappear or something happened to make them disappear. How do I get Test List back? Please don't see they are under Tests->Windows, because for me, they are not (at least now. they were!)
Anyone else seen this? Any solutions? I tried restarting Visual Studio, rebooting.
Also, previously, under the "Test" menu, there was a Debug->"Test in Context" and a Run->"Test in Context", or something like this. It was very handy. If your cursor was with in some test, you could run just that one. I'm guessing this is related.
For all I know, these features have been "optimized" into the new test-window... a.k.a. they have been removed. Some other unit test related features are also gone (the context menu item for "create unit tests" is gone for example, yet can still be called via the command window)
Personally I think this is Microsoft's way of pushing everybody towards the Team Foundation Server but that's just my two cents.
I just had the same issue. In my case I needed to install the NUnit plugin ("Nunit test adapter"). After restarting the tests came back.
Start Developer Command Prompt:
cd to UnitTest-folder\bin\Debug which contains .dll
enter command: mstest /testcontainer:UnitTestMyTest.dll
(this creates the test-result)
in VS:
menu View / Other Windows / Test Results
manage Test Runs: window Test Runs -> connect to Test Run
browse to test-folder\bin\Debug\TestResults

What Build Step should be used for running QUnit tests in TeamCity?

I've got a TeamCity build configuration with two steps currently:
MSBuild
Execute powershell sciprt
I want to add another one:
Run QUnit tests
Inside Visual Studio I use Chutzpah to run my QUnit tests. It seems that there is no "Runner type" appropriate though for QUnit tests, and because I do see one for NUnit I'm left wondering if I'm looking at this right.
Should I get a TeamCity extension to add a "Runner type" for QUnit tests? Should I create a powershell script that runs chutzpah-console? And if so how should I make sure the test output is picked up by TeamCity (do I need the /nunit2 or /junit flag?)?
I've done some research, allow me to share...
I've applied my Google-fu but that leads to a blog post with complicated QUnit tests with special TeamCity messages (or perhaps I misunderstood?) and a blog post on using a command-line build step to call PhantomJS that uses a rather contrived html file that seems like overkill to me if I'm already using Chutzpah in Visual Studio anyways (or perhaps I misunderstood)?
I've gone through the Chutzpah Full Documentation but as far as CI goes it only has a section on TFS Build, nothing on TeamCity or CI in general. I've carefully looked through the command line options documentation, and it does have one relevant option:
/teamcity :Forces TeamCity mode (normally auto-detected)
This suggests that you normally don't need to do anything to get things working, but that's certainly not the case: my sln (or better: csproj) contains several js files with QUnit tests, but TeamCity shows no tests.
So, how do I get TeamCity to run QUnit tests in the (c)leanest way possible / how do I use Chutzpah in a TeamCity build step?
No need for "service messges" or custom html files that go into a special PhantomJS call if you're already using Chutzpah. Here's one (other) way to do it in a (c)lean way.
There is no specific runner type for this type of build step. But no need for a custom Powershell script either: it'll be one line of script only. You can just use a Command Line step to invoke Chutzpah. To be more complete, assuming you've got TeamCity running already on a Windows machine, follow these steps:
Install chutzpah.console.exe. The easiest way is probably using chocolatey to install the Chutzpah package using this command in Powershell:
choco install chutzpah
This installs Chutzpah and makes sure the exe is in your path (you may need to reboot TeamCity parts to get this noticed!).
Note that alternatively you could also manually get chutzpah.console.exe on your CI server somehow (e.g. grab it from your dev machine) and reference it with a full path or place it in your path yourself.
Add a Command Line build step with a custom script like this:
chutzpah.console.exe "MyProject/UnitTestsSubDir"
E.g.:
And by some black magic this is all it takes: your tests will be run (see the build log) and TeamCity will pick up the test results.

DotCover fails unit test that pass in Resharper

Hi fellow programmers!
I'm trying to do some test coverage using DotCover 2.7 combined with Resharper 7.1.3. I have approximately 1300 tests in four different test projects in my solution, all of which pass when run with resharper. However, if i try to cover these tests using DotCover, one of the projects fails 201 tests that normally pass.
The error is that it tries to load some files from the wrong path, when run through DotCover. I have disabled all sorts of deployment, but resharper still outputs some testfiles to the folder C:\project\Src\TestResults, but these are removed once the tests have completed. When run through dotcover the following path generates the error:
C:\project\Src\project.Test4\bin\Debug\Deploy_abc 2014-07-01 13_26_56\Out\Configuration\Configuration.xml
The file it trying to find is located this folder:
C:\project\Src\project.Test4\bin\Debug\Configuration\Configuration.xml
So it seems that DotCover does not adopt the settings from resharper, or that there is some setting in the project.Test4.csproj-file which specifies this path. I have been through the csproj-file but didn't find anything, which is why i now turn to you guys.
As a bonus i can inform you that DotCover pass the tests if i run them individually, which only confuses me further.
Please advice!
Have you tried to specify path to .testsettings file? On the 'MsTest' page, click 'Use this Test Run Configuration', and then choose a .testsettings file (dotCover | Options).