Windows 10 Universal App Unit Testing project - unit-testing

I can't seem to find any information on this.. I am using it to test my Universal app but it comes with a XAML file and when I run the Unit Test it opens some screen... What is that for ? I don't need that.. I just want to unit test my code.

I think that the xaml file has something in common with UI tests, but you can still add some unit tests into that project and run them, it will start the application and blank screen will be displayed for a moment, but unit tests will run too.

Related

UWP Unit Test App Blank

I've created a UWP Unit Test App in the past and remember it working fine.
I just tried to create a new one from scratch and hit F5 (no references, one empty test method) - out of box template.
I get a successful compile and launch, however the app window is empty and does not present the UWP testing UI.
Is this a known issue, or some basic prerequisite I've overlooked?
I'm running Visual Studio 15.5.5 on Windows 10 1709 (16299.192)
Thanks
-John
The Unit Test App should not be launched directly, instead it should run through the Test Explorer. In Test menu, choose Windows, and then choose Test Explorer. In the Unit Test Explorer window click Run all. This should execute all your tests. For more information follow the walkthrough here.

second project not showing tests in test explorer

I have a solution with a test project in it, based on nUnit. All of the tests I created show in the test explorer window, I can execute, etc.
I added another unit test project to the solution, created references exactly like the first project, same nUnit version, same Platform target (Any CPU), same code structure, etc., just for a different product. But I added tests (with Test attribute) to that project and they don't show in the Test Explorer.
All of my tests in the original project still show but no tests in my new project show.
How do I get tests from multiple projects to show in the Test Explorer window?
Is the Test Explorer window tied to a specific project?
I spent a day trying to figure this out but once I posted the question, as luck would have it, I figured out the solution. I changed the nUnit version back to 3.7.1.0 and it works - both projects now show tests in the Test Explorer window.

How can I run tests locally with Xamarin Android?

All I can read about unit testing on a Xamarin Android project is about tests run on devices. But what I am looking for are business logic tests I can run pretty close to my IDE (Xamarin Studio/Visual Studio), meaning in my IDE.
Isn't there a way to do it?
If you have business logic that you can test which would not require you to run in the context of an Android device/emulator, you can use a more typical unit testing scenario. Create a C# library project and add your favorite unit testing library to it. Xamarin Studio currently supports NUnit if you want to use the test runner built into the IDE.
There is a blog post here that should help. There is a more generic NUnit tutorial on this blog post.
Open your solution and right click to choose Add > Add new Project. On the now open window click on .NET beneath the Others section. There you see NUnit library project.
This works for method testing. Unfortunately you can not test your Android project that way as far as I know.

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.

integration test - unit test seperation and best practices with visual studio 2010 + tfs

In our big application written with C# we have automated tests.
Some of tests are integration tests; they are mostly testing integration points with other systems, they are slower than unit tests and to get them to succeed on a new machine some configuration is needed.
Some are unit tests; they are much faster, do not need any configuration.
In related test projects we have two folders in general: UnitTest and IntegrationTest. Hence I have not an option to run them seperately.
What I need is, clear seperation between unit and integration tests. I want to be able to run only integration tests or just unit tests.
How can I achive this seperation? What are your experiences on the subject?
In visual studio go to the Test menu > Windows > Test List editor. All test methods can be selected/deselected in this window. At the top left click the arrow and choose Run checked tests or debug checked tests.
You can also use the TestCategory attribute (just Category in NUnit). Then run the tests in that category.
something like TestCategory("Unit") or TestCategory("Integration")