MSTest: No test discoverer is registered to perform discovery of test cases - mstest

I created a console application that was designed to be completely self-reliant and contain all the necessary DLLs to run. I was able to do this and get it to run locally, but when copying to another computer I began to receive this message...
"No test discoverer is registered to perform discovery of test cases. Register a test discoverer and try again."
I found this Microsoft bug report, but it was closed as could not reproduce:
https://connect.microsoft.com/VisualStudio/feedback/details/770093/unit-test-project-not-discovering-test-cases

I didn't want to sit around waiting for Microsoft to say they couldn't reproduce so I dug into it and found that the reason I was getting this error message is because I was missing the DLL file "Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll".
This is the file that contains the test discoverer and it needs to be in directory of the executable that is running the tests as well as the directory of the test files themselves. It is easy to miss because the assemblies to run the tests appear to be completely contained within the "Microsoft.VisualStudio.TestPlatform" namespace and the tests appear to only require a reference to "Microsoft.VisualStudio.TestTools.UnitTesting".
I decided to post this "knowledge share" post because there was no other information about the issue on the internet and Microsoft's documentation of their MSTest framework is bad at best.

Just come across this issue with some unit tests originally written in .Net 3.5 and running (or not) in vs 2013.
The UnitTestFramework.dll mentioned by Love2Learn was present however updating to .Net 4.5 seems to resolve the problem.
I'm sure someone out there can explain why but my gut feeling is that this has something to do with this being a multi-platform solution and that .Net 4.5 is just better at running 32bit unit tests against 64bit projects.

Related

CRM 2011 Online Plugin Uploader to support CI

I'm involved in developing a sandboxed Microsoft Dynamics CRM 2011 Online plugin and have a set of tests that I can drive from a xUnit front end on my local machine given that I right-click the Package and select the Deploy option (and resort to using the plugin loader sample when that doesn't work).
I'd like to be able to automate the running of my tests on my CI rig, where I'll need it to upload a fresh binary as part of each run.
We've looked at http://pluginregcrm2011.codeplex.com/ but it has bugs that prevent it working for Online and in short looks like it's no longer being maintained and I'm not keen to take ownership of what should be a fundamental tool that a platform/ecosystem should just have.
Is anyone using that tool or another plugin uploader non-interactively? Am I missing something?
I know I'm late with my answer and I`m pretty sure that you already have found a solution which is working for you.
However I felt the same pain and I have hacked a small application which could be used to simply update the plugin assembly, without doing any configuration work.
PluginAssemblyLoader -f "C:\MyPlugin.dll" -c "Url=http://crmserver/org;"
Please see http://msdyncrm-contrib.github.io/PluginAssemblyLoader
There isn't an easy OOB experience with this but the CRM 2011 Developer Toolkit just uses a set of MSBuild targets that you can call yourself. It's just MSBuild, so you could hook it into your CI build if required. If you install or just extract the Developer Toolkit MSI in the SDK you'll find the following two files in there...
Microsoft.CrmdeveloperTools.CrmClient.dll
Microsoft.CrmdeveloperTools.CrmClient.targets
As an aside it would be nice if MS would open source this as the current implementation uses predominantly sealed and internal classes within the custom tasks.

vs2010 unit tests aborting for no reason

We recently had our TFS 2008 server go down. It was rebuilt with TFS 2010 server. Now, when I selected VS unit tests and run, the first few are marked as "Aborted" and the others are "Not Executed"...
This happens without any input from me.
The unit tests were working fine before the crash.
What could be causing that?
Thanks.
I'm not sure but I have similar problem but on my local machine and with VS 2008. I cannot run some tests and have their status aborted with no reason. In the test run results I only have message "Test host process exited unexpectedly." Seems like with no reason. But I found more info on connect.microsoft.com site. The problem is my code rises StackOverflowException and it prevents the test from running. So fixing this problem heals my tests. Hope somebody it helps.
Unit test result only shows "aborted"/"test run error" for unrecoverable errors
I was getting this same issue, however in my case ALL tests were being skipped, and the error was reproducible on an empty test project, so code was ruled out.
Checking the EventViewer led me to the cause in my case; somehow the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe.config file had been removed from my machine?!? I copied one from another machine here and I'm back in action.
Same thing happened to me and as Mike said it was because I had a stack overflow exception somewhere in my code. As soon as I fixed the SO exception the problem went away. Finding the SO exception was quite hard, but I just had to step through the code until I finally found a recursive call that would cause an SO.
I suffered a similar problem which stopped me completely.
To get round it, firstly I ran the NUnit test via debug (TEST --> Debug --> All Tests) which allowed me to step through.
The error was related to the use of Entity Framework. If your project under test uses Entity Framework then the NUnit project needs a reference to EntityFramework and EntityFramework.SqlServer (or whichever provider you're using).

Debugging a Google Web Toolkit application that has an error when deployed on Google App Engine

I have a Google Web Toolkit application that I am deploying to Google App Engine. In the deployed application, I am getting a JavaScript error Uncaught TypeError: Cannot read property 'f' of null. This sounds like the JavaScript equivalent of a Java NullPointerException.
The problem is that the GWT JavaScript is obfuscated, so it's impossible to debug in the browser and I can't reproduce the same problem in hosted mode where I could use the Java debugger. I think the reason I'm only seeing the error on the deployed application is that the database I'm using on the GAE server is triggering something differently than the test database I'm using during testing and development.
So, any ideas about the best way to proceed? I've thought of the following things:
Deploy a non-obsfucated version of my application. Despite a lot of Googling, I can't figure out how to do this using the automatic deploy script provided with the Google Eclipse Plugin. Does anyone know?
Download and copy my GAE data to the local server
Somehow point my development code to use the GAE server for data instead of the local test database. This seems like the best idea...
Can anyone suggest how to proceed here?
Finally, is there a way to catch these JavaScript errors on the production server and log them somewhere? Without logging, I won't have anyway to know if my users are having errors that don't occur on the server. The GWT.log() function is automatically stripped out of the production code...
1) If you can replicate the needed state of your GAE database locally, then run the javascript compiled version on your local machine. This will almost certainly give the same error, but is a lot less expensive than a full AppEngine deployment. Do this by compiling your app with the GWT compiler, then start it normally, then point your browser to the specified address without the ?gwt.codesvr=127.0.0.1:9997 part.
2) Use the -style PRETTY or -style DETAILED with the GWT compiler to get nicer javascript. If you compile locally with this flag once, then deploying to AppEngine (with the Eclipse plugin) will send the same non-obfuscated version.
3) Instrument your code (Window.alert() works fine) to figure out exactly where the error happens. This is especially useful to find where the javascript execution deviates from the hosted mode execution.
4) Speed-up your compilation process by keeping only one permutation. See how to do this there:
How do I speed up the gwt compiler?
5) Javascript errors that don't show up in the development version or in unit tests are (almost always) due to a bug in GWT, after you've investigated a little, drop by the GWT forum or issue tracker and see if it's a known bug and whether or not there is a workaround.

easiest way to get continual unit tests running locally with visual alerts, with xUnit for C#/VS2008?

I'm currently using MSTest in VS2008 for unit tests, but I am looking at going to xUnit.net.
Question - What would be the easiest way to get my unit tests running continually locally (on my PC) and with some sort of visual alert of pass / # of fails.
i.e. similar to what we do in Ruby on Rails with autospec.
THanks
PS Intersested in hearing of the simplest open source option too.
You should also ask this on http://xunit.codeplex.com/Thread/List.aspx
There's an xUnit GUI runner and it has an auto-reload when DLLs get touched.
The missing bit is the auto-rerun of the last of executed tests when that happens. The minute we have that, you're just a Shift F6 (compile current project) away from waht you want.
The xunit.net guys are normally quite responsive, and avote on [my] http://xunit.codeplex.com/WorkItem/View.aspx?WorkItemId=8832 would help.
Regarding your other comment - I really believe xUnit.net is worth your effort using. You won't look back.
Resharper's test runner runs within VS, can run just a single test or a whole suite, and appears to support xUnit with a plugin.

Is there an API for running Visual Studio Unit Tests programmatically?

Is there an API for running Visual Studio Unit Tests programmatically?
Running MSTests.exe with Process.Start() does not work in the current scenario. What I'm looking for is something like the NUnit SimpleTestRunner.
Any ideas?
/Erik
You're correct in that there's no public API for the mstest framework. I wrote a manual replacement for mstest one day to see how hard it was, and it's not as simple as it looks (particularly if you want to take advantage of more than one CPU core), so beware of going down this path.
Personally I've always just run mstest.exe programatically and then parsed the resulting .trx XML file. Are there any particular reasons why you can't use Process.Start to run it?
P.S. Some of the strange behaviour of mstest.exe are solved if you pass the /noisolation command line parameter - give that a go if you feel so inclined :-)
Update: Erik mentions he wants to run the test API in the current thread so he can set the thread culture for globalization issues.
If you run a unit test under the debugger, you'll notice that mstest creates a bunch of threads, and runs all your tests in different threads, so this isn't likely to work even if you could access the API.
What I'd suggest doing is this:
From your test "runner" application, set an environment variable
Run mstest pointing it at the specific tests
Add a [ClassInitialize] (or [TestInitialize]) method which reads this environment variable and sets the culture
Profit!
After taking a deep dive with reflector into MSTest.exe and further down into the Visual Studio Unit Test stack, I found that the API used by MSTest is sealed up and made private so that i cannot be used from the outside.
Why not using Reflector and seeing how NUnit SimpleTestRunner is running the tests... And then use this technique...
You can make use of the Microsoft REST API's for TFS to run ms tests. Please refer to the documentation here.
I've linked to "Call a Rest API" so that you can see how you'd go about calling one of the REST API's for TFS.
Note that if your tests are linked to the build, they should run automatically every time a build is queued.
Here is the link to Run Functional Tests.
I've also discovered an article on using the TFS SDK API to run tests. Here is that link as well: Link to API Article

Resources