Running parallel test with PNunit, can't read from config file
Asked Answered
M

2

12

I wanna run pararell tests in Browserstack. This is my test project

RTest (Unit test project in VS 2013)

-UnitTest1.cs

-RTest.config

I open Nunit and browse to my dll bin/debug/RTest.dll and Nunit finds my test case

Problem My RTest.config file looks like this:

<TestGroup>
  <ParallelTests>
      <ParallelTest>
        <Name>Testing</Name>
        <Tests>
          <TestConf>
            <Name>TestFF-20-Win8</Name>
            <Assembly>RTest.dll</Assembly>
            <TestToRun>RTest.UnitTest1.TestCase</TestToRun>
            <Machine>localhost:8080</Machine>
            <TestParams>
                <string>firefox</string> <!--browserName -->
                <string>20.0</string> <!-- version -->
                <string>Windows</string><!-- os -->
                <string>8</string><!-- os_version -->
            </TestParams>
          </TestConf>
          <TestConf>
            <Name>TestFF-21-win7</Name>
            <Assembly>RTest.dll</Assembly>
            <TestToRun>Test.UnitTest1.TestCase</TestToRun>
            <Machine>localhost:8080</Machine>
            <TestParams>
              <string>firefox</string>
              <!--browserName -->
              <string>21.0</string>
              <!-- version -->
              <string>Windows</string>
              <!-- os -->
              <string>7</string>
              <!-- os_version -->
            </TestParams>
          </TestConf>
        </Tests>
      </ParallelTest>
  </ParallelTests>
</TestGroup>

My UnitTest1.cs looks like this:

using NUnit.Framework;
using PNUnit.Framework;
using System;
using System.Web;
using System.Text;
using System.Net;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

namespace RTest
{
    [TestFixture()]
    public class UnitTest1
    {
        private IWebDriver driver;
        private string[] testParams;

        [SetUp]
        public void Init()
        {
            testParams = PNUnitServices.Get().GetTestParams();
            String params1 = String.Join(",", testParams);
            Console.WriteLine(params1);
            String browser = testParams[0];
            String version = testParams[1];
            String os = testParams[2];
            String os_version = testParams[3];
            DesiredCapabilities capability = new DesiredCapabilities();
            capability.SetCapability("browserName", browser);
            capability.SetCapability(CapabilityType.Version, version);
            capability.SetCapability("os", os);
            capability.SetCapability("os_version", os_version);
            capability.SetCapability("browserstack.user", "testUser");
            capability.SetCapability("browserstack.key", "testPW");

            Console.WriteLine("Capabilities" + capability.ToString());

            driver = new RemoteWebDriver(new Uri("http://hub.browserstack.com:80/wd/hub/"), capability);
        }

        [Test]
        public void TestCase()
        {
            driver.Navigate().GoToUrl("http://www.google.com");
            StringAssert.Contains("Google", driver.Title);
            IWebElement query = driver.FindElement(By.Name("q"));
            query.SendKeys("Browserstack");
            query.Submit();
        }

        [TearDown]
        public void Cleanup()
        {
            driver.Quit();
        }
    }
}

When I run my test I recieve mInstance is null...... What am I doing wrong here?

Mali answered 30/8, 2014 at 18:47 Comment(2)
No one who can help me out here?Mali
Where you able to resolve the issue?Australorp
R
0

Try renaming RTest.config to test.conf.

Roee answered 15/10, 2015 at 11:17 Comment(0)
E
0

PNunit is from long time not maintained. I found a new open-source distributed runner that can run NUnit tests in distributed and in-parallel, you can check the projects documentation.

In general you have test controller and test agents. The test agents run your tests. First start the server

meissa.exe initServer

  1. Start the test agent on the same or multiple machines:

meissa.exe testAgent --testAgentTag="APIAgent" --testServerUrl="http://IPServerMachine:5000"

  1. Run your tests pointing the server URL

meissa.exe runner --resultsFilePath="pathToResults\result.trx" --outputFilesLocation="pathToBuildedFiles" --agentTag="NUnit" --testTechnology="MSTestCore" --testLibraryPath="pathToBuildedFiles\SampleTestProj.dll"

It is great since you don't need any configuration files or changing your code at all. It can work with both .NET Framework and .NET Core projects.

Election answered 3/4, 2018 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.