How to unit test in ScriptSharp - unit-testing

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.

Related

ReSharper Unit Test Covarage not showing coverage

When running ReSharper Unit Test Coverage in Visual Studio 2019 v.16.11.10 with ReSharper v.2021.3.3, the coverage on the files is not shown/run.
On the image, a snippet of the Unit Test Coverage is shown, where it is seen that the unit tests are run and how much of those tests are covered. Unfolding one of the packages that should be tested by the tests, it is possible to see that ReSharper cannot generate coverage. Is this because all the functionality is packed into the (1.0.0.0, .NETFramework, Version=v4.7.2)?
If this is the problem, is there any workaround? Or how do I get rid of the line if it causes any problems? If I then get rid of the line, will everything then be packaged in a different manner? Or will everything work the same as before?
One of the other projects in my team does not have this extra line where everything is packed into, and ReSharper can generate Unit Test Coverage as it should.

Typescript testing in Jasmine in Visual Studio environment

I have looked for three days straight now, and I have great problems finding a good guide to this setup:
Goal: Unit testing of functions created by developers in our team.
Solution uses Visual Studio 2015 (+ Resharper).
Solution contains Web project, which is an Angular2 based website, with code written in typescript. This typescript is what is supposed to be unit tested.
What I managed to do: Set up Jasmine as separate project in the solution. It works, I can create tests that test themselves (expect(7+1).toBe(8) kind of thing).
What I failed to do: Set up Jasmine to be able to compile .ts stuff on the fly (I guess?), to be able to reference .ts files and test them.
TL;DR: I need help setting up a Visual Studio project, in an already existing Angular2 solution, that will allow me to use Jasmine to unit test typescript files. (Perhaps someone has run across a guide that would help).
I managed to rectify my issue by redefining what I needed.
I installed karma & jasmine in the root app project (where the .ts-es are). Then used webpack to package those .ts-es along with tests (also written in TypeScript).
I used this guide:
http://ericnish.io/blog/set-up-jasmine-and-karma-for-angularjs/
Then this one:
https://templecoding.com/blog/2016/02/02/how-to-setup-testing-using-typescript-mocha-chai-sinon-karma-and-webpack/
The biggest issue was the webpack, but I have also got it to work.

Nunit tests are not found on tfs 2013 although NUnit test adapter package is used

I have a simple application and Nunit unit test project with 2 tests to test that app.
I've managed to have unit tests discovered and run locally in Visual studio 2013 but when trying to build application and run these unit tests on TFS 2013 test runner does not find tests ( both projects are built successfully.
No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
I've added "NUnit adapter with framework" package to Unit tests project according to answer in this question and committed changes to the TFS.
Unit tests projects is successfully built but still no tests are found. The Test dll fits the **\*Test*.dll naming pattern as configured in the Build Definition.
Why no tests are found? How I can make sure Test Runner is aware of my NUnit test adapter?
If you go to the build, and look in diagnostics (from the web portal), there is a Run VS Test Runner section.
In the same log, there is a Run MSBuild section, it should say "Successfully installed xxxx" where xxx is the name of your adapter package.
Something like:
Check to see that the test runner is successfully restored.
Found the reason - build agent folder in source settings of Build definition was not set correctly - instead of setting it somewhere under build agent working folder I set it outside of it that's why unit tests were not found..
I discovered this using Build process activity log (which was saved in drop folder in my case).this log contains very detailed information (much more than you can see in Visual studio) - there I found in which location test runner is looking for unit tests and then understood what i did wrong.
That's what I saw in log:
Run VS Test Runner00:00:00
Inputs
TestSpecs: BuildParameter[] Array
Enabled: True
ConfigurationsToTest: String[] Array
OutDir:
There were no matches for the search pattern C:\Builds\11\XXXX\Application -Gated\bin\**\*Test*.dll
Hope this will be helpful to someone else.
thanks to everyone who responded to my question!

TeamCity reports incorrect code coverage with dotCover for c# unit tests

I am somewhat new to TeamCity. I have set it up for a Visual Studio solution.
I am using NUnit step to run unit tests and dotCover for code coverage. Problem is, there are particular parts of my code that I know are covered by unit tests but in the code coverage report, it shows them with zero coverage.
I know the DLLs are created just fine because I run a dir /s command and can see all the test DLLs.
The NUnit step uses MSIL 4.0 platform and the test path looks like this:
**/bin/Debug/*Tests.dll
There are no filters under code coverage.
Many tests are run. But there are some specific tests that are not present in the search report when I search.
Why is this happening and how do I fix it?
Can you please provide information about your NUnit step, especially about .Net Coverage (Filters).
Can you also confirm that tests are actually run?
Full build log (pasted in pastebin.com or such provider) would be also appreciated.
Stupid me. The DLL that was being ignored was spelled *Test.dll instead of *Tests.dll. I use *Tests.dll in my test path.
The issue got fixed once I changed it to *Test*.dll

TfsBuild does not run unit tests

I'm using tfs 2010 and I want to create a tfsbuild defintion that runs unit tests.
I created unit tests and it works perfectly on my local machine.
I created a build definition, enabled tests, opened automated tests and put the vsmdi file.
the build succeed but it does not run any tests. In the build log file I don't find any information about the number of tests ran, it just tell me no test results ,besides the TestResults Directory is empty.
Has any one an idea.
I finally found the Problem. The build platform is x86 but for the test project it's AnyCPU, that's why tfsbuild did not execute tests.