How does a test-framework like Mocha run tests without a runner like Karma? - unit-testing

From what I understand about testing in Javascript, test runners like Karma are used to run the tests written in test frameworks like Mocha.
Now, my question is, how do tests execute when I input a command like mocha in my npm project without having Karma?
Is my understanding of these testing terms faulty or is there something that I am missing here?
Note: I have read that Karma is used to run tests on various browsers as well as various devices. But then how is Mocha different from it? Is it just that Mocha's output is on the terminal while Karma outputs on the browser??

Related

Code Coverage in python without unit tests

I have a python (Django) application for which I want to generate a code coverage report, but the solutions I have found on the internet mostly work with test runners or requires unit tests for example Coverage.py and pytest-cov. As I don't have unit tests for my code, is there any other options available that can do the coverage for my code without unit tests?

Golang Delve: Drop into debugger when unit test fails

I'm trying to have Delve drop into a debugger when a test from the testing package fails. How can I do this?
For reference, I'm looking for functionality similar to nose, pytest, or other python testing packages. Using nose, I can do
nosetests test_things.py --pdb
which would let me trop into a debugger when any unit tests fail.

How to unit test in ScriptSharp

We noticed that there was a unit testing project within the latest Script# 0.8 code on the Git repository, but there is no documentation as to how to actually use it, and the example files don't seem to work correctly.
Having stepped through the source code, we can't actually see any test code within the unit test files.
Has anyone else managed to successfully run unit tests against Script# within the Visual Studio IDE?
The AroundMe sample at https://github.com/nikhilk/scriptsharp/tree/cc/samples/AroundMe demonstrates unit testing.
In short, there are two parts -
1. The Tests subnamespace within your project containing tests alongside code being tested. Test code gets split out by the compiler to generate a Foo.test.js alongside Foo.js and Foo.debug.js.
A test project which provides a driver to launch unit tests in browser and capture results of QUnit to surface into VS unit testing UI. This is optional... you could run the Foo.test.js manually using QUnit yourself if you've got your own pipeline for executing tests.
Hope that helps.

How do I run only ordered tests?

In Visual Studio 11, I'm facing a complex issue.
I'm using the Unit Test Explorer to run unit-tests. However, it shows both my normal unit tests and my ordered tests, which are basically collections of tests to run in a specific order too.
That doesn't work well for me, because I would love to have the setting "Run tests after build" on. However, as you would expect, what happens is that it runs both all my tests individually out of order and then runs my ordered test as shown in the picture below.
I would really love to be able to run only my ordered tests when the build finishes. I am not interested in third-party plugins/extensions to help me do this.
I ended up using a build server, and then configured my build configuration as follows, which will run all tests with the orderedtest file extension:

Running VSTS tests without mstest.exe

From reasons I won't get into, all our unit tests are using the VSTS test framework. I now want to create an MSBuild script that runs the tests, but I don't want to use mstest.exe from various reasons (it's slower, requires Visual Studio installation everywhere, I need to maintain testrunconfig, etc.)
I've seen that TestDriven.net and TeamCity are able to run VSTS tests 'NUnit style', without using mstest.exe. Are you aware of any standalone command line utility that does this?
You can execute Team System Tests (MSTest) in NUnit if you use a special NUnit Addin that recognizes the MS Test Attributes (TestClass, etc).
Exact Magic Software has an open-source "test-adapter" that can do this.
UPDATE: I've reworked Exact Magic's Msts NUnit Adapter for NUnit 2.5.2.
Download here: http://snippetware.googlecode.com/files/ExactMagic.MstsAdapter.zip
Read more about it here: http://www.bryancook.net/2009/10/mstest-nunit-adapter.html
It seems like TeamCity is simply leveraging Gallio to run VS tests. Gallio appears to have msbuild integration and sounds perfect but after a closer look it seems that it would require a VS install just like MSTest as it appears to depend on MS exes:
The plugin enable condition was not satisfied: '${process:DEVENV.EXE} or
${process:VSTESTHOST.EXE} or
${process:QTAGENT.EXE} or
${process:QTAGENT32.EXE} or
${process:QTDCAGENT.EXE} or
${process:QTDCAGENT32.EXE}'.
Host process exited with code: 0
That being said it sounds like at least one person has got it working:
Christoph De Baene - Running MSTest without Visual Studio
It is possible to run MSTests without installing Visual Studio. See how-do-i-use-mstest-without-visual-studio.
I did this so that I could run my tests as part of my CI process. (I am using CC.NET for my CI solution).
I am in a similar situation as you, in that I want to use TestDriven.NET to get code coverage stats. But, I am running into problems. My first problem is that I am using AssemblyInitialize attributes to initialize a database connection. This isn't supported by NUnit so about half of my tests fail whereas they run fine under MSTest.
So, it seems that translating tests from one test framework to another has pitfalls. If you are aware of that, then go forth, but it might be better to try and keep consistent on one test framework.
We run VSTS tests using msbuild TestToolsTask on a Cruise Control server. This does not use the MSTEST executable -- the condition you ask for -- but does use a variety of TFS dependencies.
Note that we are migrating tests off of the VSTS test framework for NUnit, mostly because we can create extensions for NUnit to perform useful tasks.