How to debug unit test with MonoDevelop? - unit-testing

I have MonoDevelop 2.4.2 on OSX. I have a failing unit test that I would like to debug. Is there a way to do it? I found a reference on MonoDevelop mailing list but my version does not have mentioned option.
Am I missing something?

I was able to debug a unit test library by right-clicking my "unit test project" in the "Solution Explorer" and choosing "Debug Item".
I'm running the Windows version of MonoDevelop, but the same option is available on Linux and OSX versions.

On OSX monodevelop 3.0.4 this is now: Right click on unit test -> run with -> "Mono soft debugger".
You can add breakpoints using the 'run' menu too, if you need to.

I am running Xamarin Studio Community. #Kedde's answer does not work for the NUnit test in this version of the IDE. I created a Console project that runs unit tests. I am able to debug by stepping into the console methods.

Related

Eclipse CDT missing C/C++ Unit

I'm tasked with hooking up Google Test in Eclipse. I got Google Test working from the command-line, but we want it working like JUnit for Java in Eclipse. This is theoretically possible. However, running through all the online instructions I can find, they all say to use Run -> Run Configurations... -> C/C++ Unit option. For the life of me, I can't find it. Everything else is in the Run Configurations dialog, just not that item.
So I figured, even though we have Eclipse for C++ Developers installed (which should contain everything that the CDT Plug-in contains), maybe it's missing the unit testing stuff. Trying to update CDT, however, just shows that the only thing missing is the Autotools stuff (which we have no need for).
Vital statistics:
Eclipse version: Oxygen.1a Release (4.7.1a)
Operating System: Linux, CentOS
Compiler: gcc
I know that's the not the latest version of Oxygen. It's the latest we can use, because the current versions have a bug that doesn't recognize our code as valid C++.
How do I get the C/C++ Unit option in Run Configurations?
You need to install "C/C++ unit testing support" feature. Go to Help -> Install new software, select All available sites and search for it. Installing it will require Eclipse restart. After restart C++ unit test group will appear in the list of Debug configurations.

VS2013 All tests are not appearing in test exlorer

I have two projects in my solution which contains tests. I have tried clean build of solution but tests from only one project are appearing in the Test Explorer. I have also checked that Test->Test Settings->Default Processor Architecture is matching with that of project build settings (i.e. x86).
By default the Tests window will only show MsTest tests. If you have written your tests in Nunit you will need to install the 'Nunit Test Adapter' Visual studio extension for it to recognize those.
Have you tried "Kristian Kristensen's" answer to a similar question here:
How to get VS2010 to recognize my mstests generated by SpecFlow?
It worked for me.
When I set Project build settings to Any CPU it works but for any other settings (even when it matching with Test->Test Settings->Default) it fails to detect the unit tests.

Why are my MSpec specifications not recognized by ReSharper?

I know how to integrate MSpec with R#, I'm aware of "blocked DLLs" problem. But I still can't figure out why my tests are not recognized. I'm integrating MSpec in an unusual way though. I do not use NuGet. I have old MSpec build - 0.4.9 - which my tests are built for. I manually create Plugins folder for R# and put the following DLLs there:
Machine.Specifications.dll 0.4.9
Machine.Specifications.ReSharperRunner.6.1.dll 0.5.0 (built from GitHub sources)
After I start VS and open R#'s options dialog the runner is displayed in the Plugins section. But my tests are not recognized. Can the version mismatch be an issue? Does R# have any logging where I can see its communication with the plugin?
Did you try to download the 0.4.9 binaries from NuGet and use the ReSharper runner from this release? The current source doesn't support these old versions anymore.
I have finally sorted that out. I had to debug the runner as described here - https://github.com/machine/machine.specifications/blob/master/debugging-resharper.txt. And I found out that the runner was built for ReSharper 6.1.37.86, which is not the latest 6.1 release, list is here - http://resharper-support.jetbrains.com/entries/21206508-Where-can-I-download-an-old-previous-ReSharper-version-. The latest 6.1 release is 6.1.1000.82 which is installed on my machine. So the runner just could not find required ReSharper assemblies during startup. I fixed the problem by adding assembly redirects into devenv's config file. The redirects are needed for all ReSharper files the runner depends upon, there are 16 of them in total. Example redirect is:
<dependentAssembly>
<assemblyIdentity name="JetBrains.Platform.ReSharper.ComponentModel" publicKeyToken="1010a0d8d6380325" culture="neutral"/>
<bindingRedirect oldVersion="6.1.37.86" newVersion="6.1.1000.82"/>
</dependentAssembly>
For anyone coming at this problem with a Visual Studio 2019 / Resharper 2019.3.4+ setup, what worked is using Resharper's inbuilt extensions manager.
In VS, go to:
Extensions -> ReSharper -> Extension Manager
and search/install "Machine.Specifications for ReSharper"

Eclipse (CDT) plugin for running tests and browsing report

Google's answers (hear! hear!) and Eclipse Market Place search results on this topic simply drive me crazy! And apparently the proposed SO answers aren't really helpful either.
I'm looking for an Eclipse plugin, that allows me to browse a JUnit report XML compliant unit test report produced from a google test runner.
Nice to have features:
jump to the source from failure reports
run the tests automatically after building.
I'm pretty sure a (free) plugin suitable for Eclipse CDT exists, that realizes these requirements, I'm just too stupid to find it :-). May be any smarter guy/gal here?
Since JUNO there is a C++ Unit testing support package. It is package of the CDT. I only used it with boost test, but AFAIK it also supports googletest.
#mkaes comment pushed me to it!
Install the CDT (Help->Install Software->CDT) optional C/C++ Unit Test support
Create a new Runner using 'Run As -> Run Configurations -> C/C++ Unit Test
Choose 'Google Tests Runner' for 'Tests Runner' in the 'C/C++ Testing' tab
Choose your testing project executable in the 'Main' tab
Run it, and the 'C/C++ Unit' view shows up after (rebuild and) execution
Look here for more illustrated and detailed instructions: Eclipse Juno has landed with unit testing support for C++

I created NUnit tests, now how do I run them?

I'm developing in vs2008, c#, .net 3.5.
I downloaded NUnit 2.5 win / msi version. I have created a [TestFixture] Class containing several [Test] methods.
How do I run the tests?
When I run a NUnit demo solution from Ed Ames, his test .cs files have an icon in the grey column to the left of the code (same place where breakpoints, bookmarks, etc show up.) Clicking on the icon gives me an option to run the tests.
That icon is not showing up in my projects. Is there a property I need to set?
Also, the documentation refers to a NUnit GUI that can be used to run the tests. A GUI doesnt seem to have downloaded in the msi version of NUnit. Is there a separate download for the Gui?
Thanks for all your help guys.
I am using resharper, forgot to mention it.
Actually, tests were not running (no tests found in file) because my [TestFixture] class was not Public. Changed it to Public and all my tests showed up.
Also, thanks for your help finding the Gui. I was looking for an exe with GUI in the filename. But I will use Resharper to run the tests. Now that I have found them!
The demo you saw most likely had a VS plug in (Resharper, TestDriven.NET, etc.), which doesn't come with NUnit. However, NUnit installs with a GUI. Go to the folder that you installed NUnit and you will find it there.
The program is called nunit.exe and it's in the bin folder.
Once you start it, you'll need to go to File -> Open Project and find the DLL you built in Visual Studio
You can use the nUnit runner (GUI - nunit.exe in the bin folder, Console - nunit-console-x86.exe) which comes with nUnit I believe.
Alternatively, if you have resharper (http://www.jetbrains.com/resharper/) installed, it has a test runner.
There is also TestDriven.Net (http://www.testdriven.net/)
I haven't seen this demo, but it sounds very much like he is using Resharper.
If you ran the msi installer, it will have installed the NUnit GUI runner. If you browse your start menu its likely under Programs -> Nunit. From the GUI runner you can load your test assembly by navigating to the bin directory of your project.
You have to open the dll with 1) Nunit command line or 2) Nunit GUI