PNUnit Error Message when running Selenium Tests in Visual Studio

295 Views Asked by At

I'm working on trying to PNunit working for some Sauce Labs tests. But when I try launching it using the PNUnit Launcher.exe, I get the following error message:

"The test PNUnit_Test.SauceTest.TestCase couldn't be found in the assembly PNUnit.Test.dll"

Here's my sample test code:

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

namespace PNUnit_Test
{
  [TestFixture()]
  public class SauceTest
  {
    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 capabilities =  new DesiredCapabilities();
        capabilities.SetCapability("browserName", browser);
        capabilities.SetCapability(CapabilityType.Version, version);
        capabilities.SetCapability("os", os);
        capabilities.SetCapability("os_version", os_version);
        capabilities.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME);
        capabilities.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY);

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

        driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), capabilities);
    }


    [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("Sauce Labs");
        query.Submit();
    }

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

And here's the conf file I using to set up my browsers I'll be using for my test:

<TestGroup>
  <ParallelTests>
    <ParallelTest>
      <Name>Testing</Name>
       <Tests>
        <TestConf>
          <Name>TestFF-40-Win8</Name>
          <Assembly>PNUnit_Test.dll</Assembly>
          <TestToRun>PNUnit_Test.SauceTest.TestCase</TestToRun>
          <Machine>localhost:8081</Machine>
         <TestParams>
            <string>firefox</string> <!--browserName -->
            <string>40.0</string> <!-- version -->
            <string>Windows</string><!-- os -->
            <string>8</string><!-- os_version -->
        </TestParams>
      </TestConf>
      <TestConf>
        <Name>TestFF-21-win7</Name>
        <Assembly>PNUnit_Test.dll</Assembly>
        <TestToRun>PNUnit_Test.SauceTest.TestCase</TestToRun>
        <Machine>localhost:8081</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>

Not sure what I could be doing wrong and finding information about C# Selenium Testing using PNUnit is sparse, so any helpful hints will be appreciated. Thank you!

1

There are 1 best solutions below

0
On

Figured it out. My C# project was built using the .NET 4 framework. PNUnit only works with .NET 3.5. On a personal note, glad that NUnit 3 will be able to run parallel projects built on Net40 and higher