Debugging xUnit tests in Visual C# Express? - visual-studio-debugging

I have written xUnit tests for my C# solution.
Visual C# Express does not integrate with unit test tools, so people usually use external tools, and indeed I have used the external xUnit test runner so far.
But now I would like to debug a particular test within Visual C# Express, because this test crashes the xUnit test runner.
I am thinking of creating a dummy executable project that just references the unit tests project and calls the test.
Any smarter idea?

If you're willing to upgrade to Visual Studio 2012 Express for Windows Desktop, you can use the xUnit.net runner for Visual Studio 2012. Otherwise you might be able to attach to the test runner's process (Debug -> Attach to process...) and debug it that way.

I'm not sure if this functionality exists in the Express version, but you should be able to do Tools -> Attach To Process, then attach to the xunit test runner application (make sure it's running). Place a breakpoint in one of your tests, and when you Run the test(s) in the xUnit Test Runner, you should be able to debug like normal.

Related

Karma vs Chutzpah

I have been trying to figure out what is the best way to write/run automated jasmine tests in visual studio. Currently, I am using jasmine with Resharper (using PhantomJS) and the test can be run from visual studio. Now I want to run the tests as part of continuous integration and very are using TFS. Searching online give me few options which made me rather confused.
1) Use Chutzpah as a test runner to execute jasmine tests.
2) Use Karma as a test runner (but it also requires Chutzpah test adaptor for visual studio).
I get the feeling that using Karma is somewhat better than anything else but I couldn't understand the benefits of Karma instead of just using Chutzpah. Can anyone please clarify what should be the usage?
DISCLAIMER: I am the author of Chutzpah so take anything I say with a pinch of bias.
Both Karma and Chutzpah are both good tools to be able to run JavaScript unit tests. Karma is the more active open source project and has a large group of people contributing to it. It is very configurable and lets you (as Sean says) target browser besides Phantom. There are VS plugins for it as well but I have not used them much.
Chutzpah is a mature product that is also very configurable. It will always run your tests in PhantomJS but does let you open them in a new browser in order to debug. Chutzpah VS integration is mature and seamless.
The biggest benefit of Karma over Chutzpah is it can be configured to use Chrome (or any other browser) to be the test runner which makes tests a lot easier to debug with browser developer tools.

Attach/associate Selenium WebDriver Automation scripts with TFS Manual Test

I have test scripts in Selenium Webdriver using Java language. I want to attach/associate these test scripts with the manual test cases in MS-TFS. I have already done the integration between TFS and eclipse using the Add-on provided by Microsoft. Due to this I am only able to check-in/check-out the code in TFS. But not able to associate the test scripts with manual test cases.
Is there any solution for this?

Moving NUnit/ReSharper tests to Silverlight

We have a WinForms application that we're planning to port to Silverlight. Obviously the UI will need to be totally rewritten, but we have a lot of business logic that's well-tested with NUnit tests. We use ReSharper to run the tests inside the IDE, and nunit-console to run the tests on the continuous integration machines.
As we start moving our business-logic classes into Silverlight assemblies, how do we get these unit tests to run against those Silverlight assemblies? My understanding is that NUnit can't run Silverlight tests without significant tweaking, and said tweaking (in the form of a project template) appears to be VS2008- and Silverlight 3-specific (we'll most likely be using VS2010 and Silverlight 4 for our port).
We can move our tests to another testing framework if that's the best option, but there doesn't seem to be much else besides NUnit. The Silverlight Unit Test Framework looks like it runs inside the browser, which is a non-starter for continuous integration.
I'm aware that Silverlight 4.0 assemblies can be loaded into a .NET 4.0 executable, but I'm unsure of what this means for unit testing. Would it work to compile our business-logic assembly as a Silverlight 4.0 DLL, and write a full-framework .NET 4.0 NUnit test assembly that references the Silverlight DLL? It seems like this might work, but has anyone done this successfully with unit tests?
Bottom line, what should we do for our unit tests? We need a solution that
still lets us run tests in the ReSharper test runner;
can also be run from the command line;
works in VS2010.
We don't instantiate any UI objects in our tests, so those pesky DependencyObject threading issues aren't a concern. We just need to test our Silverlight business logic.
Not sure if NUnit is supported or how difficult it would be to add, but you might check out http://AGunit.codeplex.com for ReSharper Silverlight support.
I wrote a little tool to C.I. silverlight tests and attempt to help in normal dev/tdd scenarios - you can go check out http://StatLight.codeplex.com.
You should be able to find an NUnit build for silverlight out there (there's a few). Not sure of any runners that work with NUnit in the browser. However StatLight can run some basic NUnit functionality for you.
Hope this gives you a little help.

How Do I Unit Test Silverlight 3 in VS2010?

I am currently working on a project that uses the Silverlight 3 SDK and I want to create unit tests for my Silverlight code. I want these tests to not have to run in a browser context. I have referenced the Silverlight Unit Testing binaries that come in the SDK (Microsoft.Silverlight.Testing and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight) which gives me the framework necessary to write the tests (the test attributes are present).
The issue I am currently running into is that the unit tests in Silverlight are not being recognized by any test runners. Test-Driven.NET will only run the most basic of unit tests (i.e. no TestInitialize method) and Visual Studio 2010's test runner does not perceive any tests to run at all. For example, even this simple unit test will not run:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace SlUnitTests
{
[TestClass]
public class Class1
{
[TestMethod]
public void Test1()
{
Assert.Fail();
}
}
}
Any ideas?
Edit:
I forgot to mention that this project was originally a Visual Studio 2008 project. I had these unit tests for Silverlight in VS2008 using the same Silverlight 3 SDK and they ran just fine. Both the ReSharper test runner and MSTest on the command line were able to run the Silverlight-based unit tests - no browser context was required. The Silverlight unit tests broke when my project was converted to VS2010.
Sorry for the confusion.
Unfortunately there's no easy integration into the standard (non-browser) interface using these assemblies.
One option if you need to exercise basic code (no user interface code; nothing that uses System.Windows), you could create a proper class library and/or test project for full .NET in Visual Studio, and then "link" in the source files from your Silverlight project.

What is the preferred unit testing tool for C development in Visual Studio?

What is the preferred unit testing tool for C development in Visual Studio?
A quick Google search reveals a few unit testing tools for C:
Check
CUnit
I doubt they are designed to work with Visual Studio specifically, although I'm certain you'd be able to use these tools anyways as Visual Studio has good support for 3rd party tools.
I like Google Test... It provides project files for Visual Studio
And you can use Google Mock framework
CUnit is supposed to be good, but I have not used it myself...

Resources