NUnit and Selenium WebDriver - visual-studio-2013

I was working on setting up Selenium in a project today, and the thought came to mind: "Should I be using the NUnit framework in correlation with my Selenium tests?"
Here's my concern with using the NUnit framework: From the NUnit website, it states that: "NUnit is a unit-testing framework for all .Net languages". The purpose of the framework is to build unit tests, not integration tests.
Selenium tests are typically (I don't know of any instance when they aren't) integration tests. So, going back to my question, is it good practice to use a unit testing framework to do integration tests? Are there integration test frameworks that are robust enough to compete with NUnit, of which would be more appropriate?

The two main options for .NET development are, for the most part, NUnit, and MSTest. IMHO, neither are very well optimized for automated browser tests.
You can force each to do what you want, but features such as TestNG's #DataProvider are a pain to implement, especially if you are dynamically changing your data provider for each test (say, loading your browsers to test through a properties file) -- this is trivial with TestNG, but NUnit and MSTest take a significant amount of "hacking" to make it work.
TL;DR version: Someone really needs to port TestNG over to .NET :)

Related

Setting up test projects in your solution for a Xamarian app

I have experience unit testing but I have never unit tested a Xamarian solution.
My question is should I add two unit test projects to my solution? One would be a MSTest or NUnit test that tests the logic and another project Xamarian.UITest that only tests the UI? From my browsing on the internet it seems the Xamarian.UITest is only able to test the UI? Is this true or can you test the logic as well?
Thanks.
Don't try to make Xamarin.UITest test the entire application. Use Xamarin.UITest to automate the testing of the UI and, providing you have a decent separation of concerns, use xUnit, NUnit, etc, to test the logic part(s) of your app.

What does xUnit compatibility entail?

I was researching unit testing frameworks and the Wikipedia list has a column which lists whether a framework is considered the "xUnit type" or "compatible". Mocha was listed as not being of the "xUnit type" – why? What are the core features of the xUnit family?
XUnit frameworks share the following concepts:
Test runner - the program that runs the tests
Test case - Where all tests inherit from
Test fixture - the state needed to run the tests
Test suites - tests that share the same fixture
Assertion - the function that verifies the state of the test
Test formatter - shows the results un one or more formats. This is a bit tricky, since the formats are not always the same. For example, Inria's page specifies the xml tags as test-case and test-suite. JUnit, on the other hand, uses testcase and testsuite.
You can think of XUnit frameworks as *Unit... where the * is replaced by the language (e.g., JUnit for Java).
What's very tricky is that XUnit.net is different from XUnit. XUnit.net is a framework on itself that also incorporates these aforementioned concepts. The XML output format uses different tags though... such as assembly, class, etc. It can get very confusing when googling for issues.

Can chutzpah run qunit tests from a url?

Can Chutzpah run qunit tests from a url? I need a lot of server-side injected markup and json data in my qunit tests, so I like to run the test suite within my visual studio project on localhost instead of mocking tons of test data in my test.js files.
As of version 2.4 Chutzpah now supports running against a remote url. See the documentation here.
Maybe it helps to share our testing strategy.
We use chutzpah for javascript unit tests. No dependency on a running server. The tests run very quickly as part of the build. (But we are not testing generated javascript code which is your scenario).
We test against running server by writing tests in JavaScript and running them with PhantonJS. See my answer for an example of one of our tests: automated functional web GUI testing frameworks (asp.net)
If you don't like writing the tests in Javascript like this (it is not as nice as using a unit testing framework - like qUnit or jasmine) you could checked out CasperJS.

Running unit tests and integration tests separately using MSTest

We use Visual Studio 2010 Ultimate with tests written in MSTest. Both our unit tests and integration tests* are written in MSTest.
**By our definition, an integration test is an MSTest TestMethod that takes a while to run and/or calls out to external components such as a database or web services.*
I'm looking for a way of easily filtering out the integration tests so that only unit tests run without all the integration tests running too.
My ideas so far:
Mark integration tests with the [Ignore] attribute. This works but is a real pain when you do want to run the integration tests.
Assign a [TestCategory] attribute to the different test types. This allows them to be run separately but only through the Test View panel. You can't use CTRL+R, A (Run All Tests in Solution) or other similar shortcuts/hotkeys.
The integration tests are in a separate project, is there something that could be done to stop them running at the project level? As long as it's easy to toggle.
Write the integration tests in a different test framework, e.g. NUnit. This would keep them totally separate from a tooling point of view.
Does anyone have any other suggestions? Are there any plug-ins that can help with this?
I recommend having a different project (or projects) for integration tests because depending on your runner the only real way to run or not run tests across all runners is to include or not include a test class library.
But, I also recommend, if you're using MSTest, to use the TestCategoryAttribute to tag non-unit tests. You can then "filter" tests to be run in Test View with MSTest.
Runners like Resharper and apparently TestDriven.net (http://bit.ly/tmtYC2) allow you to then filter-out those tests from general unit-test executions.
If your unit test project is in a separate namespace, you could use the keyboard shortcut CTRL+R, T to run all tests in the current context (i.e. namespace MyApp.Tests.Unit). To do this place the cursor just after the opening curly brace in the namespace clause of any unit test class.
I have a suggestion but you won't like it.
Abandon MSTest entirely, while other unit test frameworks have been evolving MSTest as almost stopped in time. Yes, it has a major benefit of integrating directly with VS, but if I'm not mistaken that will change in VS 2011 which will provide native support for custom unit test runners integration.
(Note: The stopped in time part may be not true because I confess not paying to much attention to MSTest since I used it sparingly with VS 2008)
I use NUnit and separate my unit tests from the integration tests by using a different class library project. Then I automate the running of the tests using Gallio command line runner allowing me to configure separate scripts for running unit and integration tests.
Finally, personal opinions aside, I'm not sure but the TestDriven.net plugin may have support for running tests with a specific category only, so you could check that.

Software required to automate test cases using WatiN

Can anybody please tell me which softwares are required to automate tests of a .NET web application using WatiN.
Thanks
Any unit test framework like NUnit will let you do it. If you want to test against the development web server, that's slightly trickier, but possible.
Reference WebDev.WebHost.dll (in the GAC, but can be extracted and referenced on its own as it has no non-framework dependencies) in your unit test, then you have use the Server class it exposes to fire up a development web server. This is the server fired up by the development webserver executable, but this doesn't give you a neat shutdown option - the Server class however does!
I suggest using Watin and MBUnit. MBUnit has a really good test runner called Gallio and is easy to work with.
http://www.gallio.org/

Resources