简体   繁体   English

使用PNunit运行并行测试,无法从配置文件中读取

[英]Running parallel test with PNunit, can't read from config file

I wanna run pararell tests in Browserstack. 我想在Browserstack中运行pararell测试。 This is my test project 这是我的测试项目

RTest (Unit test project in VS 2013) RTest(VS 2013中的单元测试项目)

-UnitTest1.cs -UnitTest1.cs

-RTest.config -RTest.config

I open Nunit and browse to my dll bin/debug/RTest.dll and Nunit finds my test case 我打开Nunit并浏览到我的dll bin / debug / RTest.dll,Nunit找到我的测试用例

Problem My RTest.config file looks like this: 问题我的RTest.config文件如下所示:

<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: 我的UnitTest1.cs看起来像这样:

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? 当我运行我的测试时,我收到mInstance为空......我在这里做错了什么?

尝试将RTest.config重命名为test.conf

PNunit is from long time not maintained. PNunit很长一段时间没有维护。 I found a new open-source distributed runner that can run NUnit tests in distributed and in-parallel, you can check the projects documentation . 我发现了一个新的开源分布式运行器,可以在分布式和并行运行NUnit测试,您可以检查项目文档

In general you have test controller and test agents. 通常,您有测试控制器和测试代理。 The test agents run your tests. 测试代理运行您的测试。 First start the server 首先启动服务器

meissa.exe initServer meissa.exe initServer

  1. Start the test agent on the same or multiple machines: 在相同或多台计算机上启动测试代理程序:

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

  1. Run your tests pointing the server URL 运行指向服务器URL的测试

meissa.exe runner --resultsFilePath="pathToResults\\result.trx" --outputFilesLocation="pathToBuildedFiles" --agentTag="NUnit" --testTechnology="MSTestCore" --testLibraryPath="pathToBuildedFiles\\SampleTestProj.dll" 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. 它可以与.NET Framework和.NET Core项目一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2013调试找不到配置文件 - Visual Studio 2013 debug can't find config file Apache Cordova无法从根目录读取文件 - Apache Cordova Can't Read a File from Root Directory CodedUI测试不从CSV输入文件中读取数据 - CodedUI test does not read data from CSV input file Microsoft Test Agent 2013配置文件的位置 - Location of Microsoft Test Agent 2013 Config File c# 单元测试 - 似乎无法在运行时获得我的测试文件的相对路径 - c# unit test - can't seem to get a relative path to my test file at run time 从配置文件更改Resharper中的命名样式 - Change the naming style in Resharper from a config file 为什么readImageLists无法读取txt文件中的图像列表? - Why does the readImageLists can't read my image list in txt file? SSDT单元测试:。 从配置文件读取SQL Server单元测试设置时发生错误 - SSDT Unit Test:. An error occurred while SQL Server unit testing settings were being read from the configuration file 如何防止resharper 8与nunit一起运行并行测试? - how do I prevent resharper 8 from running parallel tests with nunit? 从Windows窗体运行测试时,TestContext为null - TestContext is null when running test from a Windows Form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM