0

ライブラリ「Baseclass.Contrib.SpecFlow.Selenium.NUnit」とともに SpecRunner を使用したいと考えています。Manage Nuget Packages から SpecFlow 2 の SpecRunner を追加したとき、単体テスト プロバイダーは app.config の 'SpecRun' でした。次に、Manage Nuget Package を使用してソリューションに「Baseclass.Contrib.SpecFlow.Selenium.NUnit」を追加すると、「SeleniumNUnit」の単体テスト プロバイダーも追加されました。機能ファイルとステップ定義を作成し、各機能に「@Browser: Chrome」などのブラウザー タグで注釈を付けてテストを実行し、バインド メソッドで Web ドライバーとして「Browser.Current」構文を使用しようとしたところ、エラー。最初のエラーは、app.config に 2 つの単体テスト プロバイダーがあり、app.config には単体テスト プロバイダーを 1 つしか持てないことでした。そのため、最初の単体テスト プロバイダーをコメント アウトしました。

*エラー 2 #エラー: '生成エラー: ファイルまたはアセンブリ 'TechTalk.SpecFlow、バージョン = 1.9.0.77、カルチャ = ニュートラル、PublicKeyToken = 0778194805d6db41' またはその依存関係の 1 つを読み込めませんでした。システムは、指定されたファイルを見つけることができません。' C:\Users\amadox\documents\visual studio 2013\Projects\SpecFlow\SpecFlow\SpecFlowFeature1.feature.cs 1 8 SpecFlow *

* エラー 33 カスタム ツール エラー: 生成エラー: ファイルまたはアセンブリ 'TechTalk.SpecFlow、バージョン = 1.9.0.77、カルチャ = ニュートラル、PublicKeyToken = 0778194805d6db41' またはその依存関係の 1 つを読み込めませんでした。システムは、指定されたファイルを見つけることができません。C:\Users\amadox\documents\visual studio 2013\Projects\SpecFlow\SpecFlow\SpecFlowFeature1.feature 2 2 SpecFlow *

そこで、最初のユニット テスト プロバイダーのコメントを外し、2 番目の単体テスト プロバイダーのコメントを外してみました。同じ問題。「Baseclass.Contrib.SpecFlow.Selenium.NUnit.Bindings」が提供するパラメーター化されたクロス ブラウザー テスト機能の柔軟性と共に、Visual Studio 2015 で SpecRun を実行するにはどうすればよいですか? 以前のバージョンの Specflow (1.9) に戻すように求められているようで、Specflow 2 を使用しています。これを行う方法がわかりません。この問題を解決するにはどうすればよいですか?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" /></configSections>
  <specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
  <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><!-- use unit test provider SpecRun+NUnit or SpecRun+MsTest for being able to execute the tests with SpecRun and another provider --><unitTestProvider name="SpecRun" /><plugins>
      <add name="SpecRun" />
    <add name="Baseclass.Contrib.SpecFlow.Selenium.NUnit" path="..\packages\Baseclass.Contrib.SpecFlow.Selenium.NUnit.1.3.1\tools" /></plugins><unitTestProvider name="SeleniumNUnit" /><stepAssemblies>
      <stepAssembly assembly="Baseclass.Contrib.SpecFlow.Selenium.NUnit.Bindings" />
    </stepAssemblies></specFlow>
<appSettings>
    <add key="seleniumBaseUrl" value="http://localhost:58909" />
  </appSettings><autofac>
    <components>
      <component name="IE" type="OpenQA.Selenium.IE.InternetExplorerDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
      </component>
      <component name="Chrome" type="OpenQA.Selenium.Chrome.ChromeDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
      </component>
      <component name="Firefox" type="OpenQA.Selenium.Firefox.FirefoxDriver, WebDriver" service="OpenQA.Selenium.IWebDriver, WebDriver" instance-scope="per-dependency">
      </component>
      <!-- Example of using an injected RemoteDriver:
      <component
              name="IE"
              type="Baseclass.Contrib.SpecFlow.Selenium.NUnit.RemoteWebDriver, Baseclass.Contrib.SpecFlow.Selenium.NUnit.SpecFlowPlugin"
              service="OpenQA.Selenium.IWebDriver, WebDriver"
              instance-scope="per-dependency">
        <parameters>
          <parameter name="url" value="http://127.0.0.1:4444/wd/hub" />
          <parameter name="browser" value="InternetExplorer">
          </parameter>
        </parameters>
      </component>-->
    </components>
  </autofac>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="TechTalk.SpecFlow" publicKeyToken="0778194805d6db41" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

*

4

2 に答える 2

0

Baseclass.Contrib.SpecFlow.Selenium.NUnit を少し見てみると、SpecFlow 1.9 に依存しています。使いたい場合は、SpecFlow 1.9 に固執する必要があります。さらに、独自の GeneratorPlugin を作成してカスタム コード ビハインド ファイルを生成しているようです。

独自のジェネレーターがあるため、SpecFlow+Runner とは連携しません。

また、構成内の 2 つの unitTestProviders が機能しません。

ただし、SpecFlow+Runner には「ターゲット」と呼ばれる機能があり、http://www.specflow.org/plus/documentation/SpecFlowPlus-Runner-Profilesを参照して検索してください。

ブラウザーごとにターゲットを作成し、ConfigFileTransformation ステップを使用して、さまざまなブラウザーの構成を調整できます。

別の方法ですが、これが機能するかどうかはわかりません。SpecFlow+Runner は SpecFlow 1.9 をサポートしており、NUnit テストを実行できます。SpecRun.SpecFlow.1-9-0 nuget パッケージを使用し、unitTestProvider を baseClass のいずれかに構成します。それらが標準の NUnit 属性を生成する場合、SpecFlow+Runner はテストを見つけて実行できるはずです。ただし、その方法では一部の機能が失われることに注意してください。

完全な開示: 私は SpecFlow と SpecFlow+ の開発者の 1 人です。

于 2016-07-14T17:53:48.607 に答える