2017-05-08 6 views
0

現在、Specflowでプロジェクトをデザインしています。私は私のプロジェクトにいくつかの報告を実装したい。現在、私は1つの別個の.csファイルを作成し、すべてのレポート設定を保持しています。しかし、これらのステップは到達不能になっています。誰も私の流れをどのように設計でき、どのようにフィーチャファイルと統合できるのか教えてください。 以下のBaseReport.csファイルとステップ定義ファイルを確認してください。Specflowプロジェクトでレポート(エクステントレポート)を生成する方法

namespace Verivox.CommonLib 
{ 

    public class BaseReport 
    { 
     public static ExtentReports extent; 
     public static ExtentTest test; 

     [BeforeFeature()] 
     public static void BasicSetUp() 
     { 
      //string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase; 
      string pth = System.IO.Directory.GetCurrentDirectory(); 
      string actualPath = pth.Substring(0, pth.LastIndexOf("bin")); 
      string projectPath = new Uri(actualPath).LocalPath; 

      string reportPath = projectPath + "Reports\\" + FeatureContext.Current.FeatureInfo.Title + ".html"; 

      extent = new ExtentReports(reportPath, true); 

      extent.LoadConfig(projectPath + "CommonLib\\Extent-config.xml"); 

     } 

     [BeforeScenario()] 
     public static void BeforeScenarioSetUp() 
     { 

      test = extent.StartTest("Running Scenario -->" + ScenarioContext.Current.ScenarioInfo.Title); 
     } 

     [AfterScenario()] 
     public static void AfterScnario() 
     { 
      if (ScenarioContext.Current.TestError != null) 
      { 
       var error = ScenarioContext.Current.TestError; 
       var errormessage = "<pre>" + error.Message + "</pre>"; 
       //Add capture screen shot line here 

       extent.EndTest(test); 

      } 
     } 

     [AfterFeature()] 
     public static void EndReport() 
     { 
      extent.Flush(); 
      // extent.Close(); 
     } 
    } 
} 

ステップ

namespace Verivox.Steps 
    { 
     [Binding] 
     class CalculationVerificationSteps 
     { 
      [Given(@"I have navigate to Home Page")] 
      public void GivenIHaveNavigateToHomePage() 
      { 
       Browser.Current.Navigate().GoToUrl(ConfigurationManager.AppSettings["seleniumBaseUrl"]); 
       PropertyCollection.currentPage = new HomePage(); 
       Browser.Current.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); 

      } 

      [Given(@"Navigate to Mobile Calculator under All Comparison Section")] 
      public void GivenNavigateToMobileCalculatorUnderAllComparisonSection() 
      { 

       PropertyCollection.currentPage.As<HomePage>().MainCompItemClick("Telekommunikation"); 
       PropertyCollection.currentPage.As<HomePage>().SubCompItemClick("Mobilfunk"); 
       PropertyCollection.currentPage.As<HomePage>().CalculatorLinkClick("Mobiles Internet"); 

      } 

      [Then(@"Mobile Calculator should appear")] 
      public void ThenMobileCalculatorShouldAppear() 
      { 
       Assert.IsTrue(PropertyCollection.currentPage.As<HomePage>().IsMobileInternetCalcExistance()); 
      } 

      [Then(@"(.*) option and (.*) option is selected by default\.")] 
      public void ThenMonatsflatrateOptionAndSIMOptionIsSelectedByDefault_(string defaultTarif, string hardware) 
      { 
       try 
       { 
        Assert.IsTrue(PropertyCollection.currentPage.As<HomePage>().VerifyMobiIntSelectedItem(defaultTarif)); 
        string colorCode = PropertyCollection.currentPage.As<HomePage>().VerifySelectedHardWare(); 
        Assert.AreEqual(0, string.Compare("rgba(253, 138, 2, 1)", colorCode, StringComparison.OrdinalIgnoreCase)); 
       } 
       catch (Exception) 
       { 
        BaseReport.test.Log(LogStatus.Fail, "Default selections are incorrect."); 
       } 


      } 
+0

コードの書式を修正してください。それは少し読めないです。 –

答えて

0

あなたはBaseReportクラスのBinding-属性が欠落しています。これがなければ、そこに定義されているフックは呼び出されません。

関連する問題