I have a .Net 4.0 test assemby and I am running nunit-console-x86.exe that fire an nunit-agent-x86.exe process.
Do you know if the runner pass the /nothread option to nunit-agent-x86.exe?
I have noticed that my tests run successfully when they are executed inside the runner process with that option set (and with a modification of the runner configuration file to target the CLR 4.0)? I am using the version 2.6.4 of Nunit.
As runners are chained together, the same package is passed from one to the other. That package is created with a setting that reflects the use of /nothread, so every runner receives it, no matter what process they are in.
You haven't indicated why you need that option in the first place. It's a rather strange option, since it says you prefer that the tests be run on the same thread that is used by NUnit itself, rather than creating a new one.
I need the /nothread option because some of the objects I instantiate during my tests are COM objects and they need to be instantiated in the main STA thread.
Related
I have a TeamCity build configuration that builds a C# project, runs some unit tests, and then does some extra things. My question is: Can I get information about my unit test run stored into build configuration variables (i.e. how many tests were run, how many were successful, how many failed, how many were skipped) so that I can then check these variables in a PowerShell script in later build steps and perform different actions depending on how many tests have passed?
AFAIK the best way is to ask these information directly to teamcity server using its REST API (pay attention, maybe the build locator could be a little be tricly to be found, if the build is still running).
By other hand, you can parse your NUnit test result file (or files if you run more than one NUnit test runner step in your build) inside your build agent machine.
I'm using VS 2013 and NUnit.
I'm running my tests in Resharpers's TestRunner GUI - this thing:
I have multiple projects (Solution.Foo, Solution.Bar, etc), and tests for each project in Solution.Foo.Tests, Solution.Bar.Tests, etc.
One of my tests in Foo.Tests is accessing a file, located in the Solution.Foo.Tests Folder.
I use TestContext.CurrentContext.TestDirectory to locate it and when I run that test it all works just fine.
If I run the whole suite of tests in Foo.Tests, (i.e. click on Solution.Foo.Tests in the Runner GUI and run) then it's fine.
But if I select one test from Bar.Tests and my file-reading test from Foo.Tests, then it fails, because suddenly TestDirectory is set to a path in Bar.Tests.
It's as if NUnit set TestDirectory once when it starts running a collection of tests, determined by where the first test is and then never updates it again.
Any ideas what's going on and how to fix it?
ReSharper has an optimisation for speed, by sharing an AppDomain across multiple assemblies. The downside to this is that it will pick an arbitrary assembly to be the main one, which means the directory can be wrong (and it might not pick up the correct app.config, too).
You can disable the optimisation in ReSharper → Options → Unit Testing, by checking the "Use separate AppDomain for each assembly with tests".
Today I have a strange problem on MacOs. I hope I can explain the precondition exactly for understanding. We are using the install4j version 6.0.1.
Our application is implemented with an install4j silent update check application as the main "launcher" to check for updates during the startup process of our application. This application is totally configured by the install4j IDE. It checks whether an update exists and for that downloads the new installer and executes it. That's working fine. If the application is up-to-date the "main" application launcher will be executed by the Execute Launcher-action. Therefore the "extraCommandLineArguments" will be passed to the launcher and the application will be started. That's working also fine and the parameters will be passed correctly to our main class.
Now the strange behavior: when I start the application twice with several parameters during the first instance is always running the parameters will not be passed to the first instance neither a second instance will be created. The launcher is configured by install4j to allow multiple instances of the application and the single-instance option is implemented by our application itself. Therefore the main-class checks whether an instance is always running and will pass the parameters to the first instance. Now it seems that the second instance will never be created because I can't attach to the vm-process by IDE at debug mode. Therefore I set the debug vm parameters to the vmoption file. I tried several options to start the second instance:
execute our application normally with the "updater"-application and set commandline parameters
execute our application directly by the launcher-executable and set commandline parameters
execute our application by calling the JavaApplicationStub of the launcher and passing the commandline parameters to it
For all options the running instance will get the focus but do not receive any parameter and I can not attach the second process by the IDE to debug the behavior. It seems our application (main-class) will not be executed a second time. At the Info.plist file there is the MacLauncher class recognized as the main-class. Is tere any logic implemented to search for a running instance and ignore a second one?
The strange thing is: at windows everything works fine. The second process passes the parameter to the running instance. What could be different on mac? How can I check whether install4j is calling our main application class configured at the launcher? Are there any debug-options?
Thanks in advance for any help.
On Mac OS X, GUI applications are in single instance mode by default. This is a property of the Mac OS X desktop environment. The only way to open a second instance, is to call
open -n my.app
I'm playing around with Microsoft Test Manager 2013 (though it appears it is just MTM2012) to try and get a better understanding of test cases and test suites as I want to use this at work. So I was hoping that I could run a test suite on a build which gets included in this test suite. That is what I WANT to do, but it could very well be wrong. So maybe a better scope of what I'm doing at work might lend to a better answer.
My company makes tablet PC's. I write programs for those tablets. For sake of argument lets just say there are 5 tablets, that run a similar array of OS's. Tablet1,2,3 and 4 can run WinXP, WinXP embedded, Win7, and Win7 Embeded, and Tablet5 can run Win7, Win7 Embedded, and Win8 embedded. Lets say i'm making a Display test program. Naturally this display test will run differently on each tablet, but the program it self is supposed to be able to handle that along with not being able to worry about OS. So I wrote out a very simple test. Open Program, try to open again, verify only 1 instance, check display, close program.
I figured it would be good to make a Test Suite called "Complete Display Program Test" and put 5 sub test suites to that for each tablet. Then moved the 5 test cases to a single test suite. I configured all test cases to only have the correct tablet/OS configuration. Queued a build and waited for it to finish. I then attached that build to the main test suite. I then clicked on run a test for tablet 1 but I didn't see the build attached to the test runner. I've looked around a little bit to see why or how and haven't found anything. Question is is how do I do that? Or if you are scratching your head and wondering why in the world I am doing it this way then by all means suggest another way. This is the second time I have ever looked into MTM so I might not be doing it right.
Thank you for your time.
When running manual tests from MTM you will not see the build you are using in Test Runner.
But if you complete the test and set the test outcome you will be able to check which build you've ran the test against.
Just double-click on the test or select "View Results" to display test results:
This column is not visible by default. You will have to right-click on the column row and select the column "Buld number" to be displayed.
You will also be able to see the build number in "Analyse Test Runs" area:
The things are slightly different if you are running automated test.
Consider following approach:
Automate your Test Cases
See How to: Associate an Automated Test with a Test Case for details.
Create a Build Definition building your application under test AND assemblies containing your tests.
I strongly recommend build application you want to test and test assemblies using in the same Build Definition. (You will see why a little bit later).
Run this build definition and deploy the latest version of the application to the environment where you want run the tests.
This is very important to understand: if you run automated tests the tests assemblies only would be deployed automatically to the environment.
It's your job to deploy the right version of the application you are going to test.
Now you can run tests from MTM.
You can do it the way described by #AndrewClear in the comment to this answer: "choose "Run with Options" when you're beginning a test run" and select the latest build.
Now test assemblies containing tests which are using to automate Test Cases will be deployed automatically to the test environment and the tests will be executed.
That is the point you should recognize why is it so important to build application and tests with a single Build Definition: since the build number you've just selected when starting the tests will be stored along with the test results on TFS you will later know what version of you application you were testing (assuming you deployed the right version, of course).
You could go a little bit further if you want even more automation (This is the way I'm currently running automated tests)
Use Deploy-Build-Test template (this is a good place to start reading about Setting Up Automated Build-Deploy-Test Workflows).
Using this approach you will be able to automate deployment of the application you want to test.
I have a command-line application that I want to run in a build configuration for the duration of the build, then shut it down at the end when all other build steps have completed.
The application is best thought of as a stub server, which will have a client run against it, then report its results. After the tests, I shut down the server. That's the theory anyway.
What I'm finding is that running my stub server as a command line build step shuts down the stub server immediately before going to the next build step. Since the next build step depends on the server running, the whole thing fails.
I've also tried using the custom script option to run both tools one after another in the same step, but that results in the same thing: the server, launched on the first line, is shut down before invoking the second line of the script.
Is it possible to do what I'm asking in TeamCity? If so, how do I do it? Please list any possibilities, right up to creating a plugin (although the easier, the better).
Yes you can, you can do that in a Nant script, have Teamcity run the script, look for spawn and the nantContrib waitforexit.
However I think you would be much better off creating a mock class that the client uses only when running the tests. Instead of round tripping to the server during the build as that is can be a bit problematic, sometimes ports are closed, sometimes the server hangs from the last run, etc. That way you can run the tests, make sure the code is doing the right thing when the mock returns whatever it needs to return etc.