I'm calling nunit test from Jenkins and I need to be able to specify just one URL address as parameter which I can use inside test. Is there possibility to do that?
For example I'm calling "Execute Windows batch command" in Jenkins like that:
"C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe" "D:\selenium\SeleniumTest.dll" /run:SeleniumTest.Test.MyTest
Any ideas?
As far as I currently know of, there is no solution to provide just that what you describe that you want. Best option is to use NUnit project files, modify settings there and pass the solution file to the runner.
On the other hand, you could try to use the Environment variable.
Use set from the command-line. Then read the value using Environment.GetEnvironmentVariable() and use that within your testmethod.
Related
I need to run my Speflow feature file with Nunit 3.6 console. Just need to know how can i run specific feature? As fixure is not supported anymore so just need to know what else can be used? Tried --test = but no luck.
I've tried below command line
%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe "C:\jenkins\workspace\Nunit_ME_Test\Automation\Automation.csproj"
C:\nunit\nunit3.7.0\nunit3-console.exe C:\jenkins\workspace\Nunit_ME_Test\Automation\bin\Debug\Automation.dll --test=ME_NTJ_Include
I have used -test=ME_NTJ_Include where "ME_NTJ_Include" is the feature file .I'm sure something is not right , can any one please help to resolve this .
Thanks
To learn exactly how SpecFlow is naming your tests at different levels, simply run all of them and examine the XML result file. The name you find there for FullName is what you would have to use with the --test option. Most likely, you are simply issing the namespace in which the fixture is defined.
For more flexibility, use the --where option. That would allow you to write, for example --where test=~ME_NTJ_INCLUDE for a partial match of the name.
I have programmed an console application with c# for ranorex automation.
Within the exe i have build i would like to kick off the specflow feature files manually.
I believe I need to create a TestRunnerManager and trigger the run.
Can anyone help?
Although not familiar with nunit, I guess like with mstest, attributes are used to mark methods in an assembly as tests. You could use reflection to find these methods in the assembly and invoke them
This question is similar in spirit to one I asked a while back about MsTest (How do you run SpecFlow scenarios from the command line using MSTest?).
Remember that SpecFlow feature files become C# classes. Scenarios within a feature file become test methods. You can use the nunit-console command line utility to run these:
nunit-console /fixture:Your.Test.Project Your.Test.Project.dll
Which should run all the tests in the Your.Test.Project namespace.
When annotating scenarios using #CategoryName:
#Feature1
Scenario: Some cool feature
Given ...
You should be able to run those from the command line as well:
nunit-console /include:Feature1 Your.Test.Project.dll
Note: This is from an older version of NUnit. Current documentation: https://github.com/nunit/docs/wiki/Console-Command-Line
I use MsTest with Specflow, so my examples might not be correct, but this should put you on the right path. Just look at the *.feature.cs files generated by the .feature file to give you some hints.
No need to create your own console application to run these tests. Worst case scenario, create a batch file or PowerShell script to kick off the tests you want.
I am trying to run a feature file with NUnit Console. I tried googling it and checked NUnit3 help also. But I am unable to find any help.
I want to run either single feature file or any scenario in a feature file which has tag assigned. I am using specflow with specrun. I tried NUnit console command for where "test == path of feature file" but it is not executing test. However I am able to execute all test cases by giving project dll file path. But I just want to execute a single feature file or single scenario in a feature file. Please let me know how can I do this so that I will be able to generate NUnit testresult.xml file.
Thanks.
if you are using SpecRun then you can use the command line of SpecRun to run the tests.
If you really want to use NUnit then you first have to make sure that the project containing the feature files has been compiled. Once you have a test dll this will contain the NUnit tests just like any other and the test categories will be set based on the tags, so you can execute them all by telling NUNit to run tests in the test dll, or you can run tests which have a Tag by telling Nunit to run tests which are in a category matching the Tag.
Running just a feature will be more tricky as there is nothing which groups the scenarios by feature in the tests I don't think, though I may be wrong.
instead of test==featurefile use name==FeatureName
I would like to be able to pass a system argument - "host" to the MStest suite. To create automated jobs for continuous integration, I want to be able to specify the host as a parameter so the tests are run on that specific host. I couldn't find any such option with mstest.
In Java, -Dhost="localhost" would work which can be specified as a parameter for the running VM. Is there a similar way in MStest for C#?
There is not an equivalent to the Java system properties that you mention. Here are a couple of ideas on how to approximate what you are looking for:
[1]
Visual Studio test support does include Test Run Configurations (renamed Test Settings in Visual Studio 2010). This is a file that specifies many settings that control aspects of the test run. For example, you can deploy additional files alongside your test, or run a "setup" batch script before your test run begins.
If you have a finite set of hosts, you could have a separate test run config/test settings for each host. Each config/settings would deploy a file that contains the name of a different host. You could then read in that file as part of your unit test setup, perhaps from your [TestInitialize] method. A bit hokey, but maybe it would do what you want.
[2]
You could set a system environment variable (e.g., "TESTHOST") before running the test, and then read that environment variable from your tests. You could wrap all of this up in a simple program or batch script that accepts an argument to set the environment variable, invoke mstest, and unset the environment variable afterwards. For example, this StackOverflow post may give you some ideas on how you might do something like this using PowerShell.
I don't believe there is an exact equivalent. Instead, try leveraging .NET configuration files:
Add an application configuration file (App.config) to your MSTest project. Add your "system" properties as keys in the appSettings section. Reference these values in your tests using the ConfigurationManager.AppSettings collection.
In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument.
How do you get the arguments from MSTest?
VS 2008 test are compiled into DLLs which can't directly receive command line arguments as far as I know.
You could add a configuration file 'app.config' for the dll and use that instead.
Just beware, mstest only copies .config files for the test container being run at the time.
if you have the following...
mytest.dll
mytest.dll.config
lib.dll
lib.dll.config
and you reference lib.dll from mytest.dll, when you run the tests lib.dll.config will not get copied and your test may fail because of this.
Perhaps you can use GetCommandLine().
Edit: GetCommandLine() is a win32-function, but there ought to be a corresponding .Net function for it.