-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C# Specflow - BeforeTestRun hooks not executing with multiple project in single solution #207
Comments
I already went through below issue. However I'm not making such mistake. I'm already using objectcontainer. |
I'm getting below error message during execution from team server. |
I was experiencing this issue as well, but I found the reason was that I was incorrectly referencing SpecFlow.NUnit.Runners in a class library in the solution that I referenced from the actual test project. I fixed the issue by ONLY referencing the core SpecFlow package in the class library, and only referencing SpecFlow.NUnit.Runners from the actual test project. Issue cleared up after that and BeforeTestRun/AfterTestRun worked as expected. I have multiple test projects in my solution as well and they're all working now. I'm not sure if this is the same issue others are experiencing, but hopefully this helps. |
Used Visual Studio
Visual Studio 2019
Are the latest Visual Studio updates installed?
Yes
SpecFlow Section in app.config or content of specflow.json
Debug AnyCPU {47BA4404-C1D3-49FA-BB5A-F513CDA20BAB} Library Properties MBV.Foundation.customer.Testing MBV.Foundation.customer.Testing v4.7.1 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages False UnitTest true full false bin\Debug\ DEBUG;TRACE prompt 4 AnyCPU pdbonly true bin\Release\ TRACE prompt 4 3.3.14.5 4.7.0 3.12.0 1.4.1 6.0.1 1.0.7 3.6.0 3.6.0 3.1.3 25.0.2 3.7.0 1.4.9.5 1.4.9.5 3.0.0 2.7.2 2.7.2 2.7.2 2.1.0 2.1.0 12.0.1 3.11.1 3.11.1 3.16.1 106.11.4 3.141.0 3.141.0 104.0.5112.7900 0.26.0.1 3.150.1 3.3.30 3.3.30 3.3.30 4.3.0 4.3.0 4.3.4 4.3.0 4.3.0 4.3.0 4.0.0 4.3.0 4.3.0 4.3.0 4.3.0 4.4.0 4.4.0 1.3.7 3.9.0 Always Designer {3087EEDF-0173-4D9E-B5F4-BA42D8F31F7E} MBV.Foundation.Accounts {1644e893-9f94-4398-837b-381f95cf40da} MBV.Foundation.api.Testing {80366ec9-5928-44b0-b80d-cc38bc13033d} MBV.Foundation.ecom.Testing {b8c307f7-d49b-475f-857f-30f63948f90c} MBV.Foundation.Specflow.TestingIssue Description
when I use [BeforeTestRun], the method is not even called during run in CI in teamcity. While this is working fine in debugging. I'm using hook file. I searched here for solution in many questions. Also I'm using multiple projects in single solution. Each project has its own hook file.
using AventStack.ExtentReports;
using AventStack.ExtentReports.Gherkin.Model;
using AventStack.ExtentReports.Reporter;
using BoDi;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Reflection;
using TechTalk.SpecFlow;
namespace MBV.Foundation.ecom.Testing.GeneralHooks
{
[Binding]
public class Generic
{
private static ScenarioContext _scenarioContext;
private static ExtentReports _extentReports;
private static ExtentHtmlReporter _extentHtmlReporter;
private static ExtentTest _feature;
private static ExtentTest _scenario;
private readonly IObjectContainer _objectContainer;
private IWebDriver driver;
Steps to Reproduce
Due to above [BeforeTestRun] not executing, I'm getting error in [BeforeFeatureStart] for '_extentReports' variable is null. Because this is being initialized in [BeforeTestRun] as per above hook file.
Link to Repository Project
No response
The text was updated successfully, but these errors were encountered: