SpecFlow+ 3, dotnet core 2.1, report template, trace logs, TextContainer message, JavaScript logs, IObjectConainer

51 views
Skip to first unread message

László Radnai

unread,
Jan 18, 2020, 6:00:55 PM1/18/20
to spe...@googlegroups.com
I'm migrating to SpecFlow+ 3, dotnet core 2.1 by creating a new project, and adding the old tests, and also improving them, for example to use IObjectContainer.
Can you give me some ideas how how to fix the issues below?

Issue 1. Report generating works, I can edit the report template manually, but cshtml format is not recognized by VS2019, so I always have tons of warnings/errors.
I tried adding Microsoft.AspNet.Razor or Microsoft.AspNetCore.Mvc.Razor NuGets, but no luck.

ReportTemplateIssue.jpg









The current NuGets in the project:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="FluentAssertions" Version="5.10.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.10" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
    <PackageReference Include="Selenium.Support" Version="3.141.0" />
    <PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
    <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="79.0.3945.3600" />
    <PackageReference Include="SpecFlow" Version="3.1.74" />
    <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.74" />
    <PackageReference Include="SpecRun.Runner" Version="3.1.38" />
    <PackageReference Include="SpecRun.SpecFlow.3-1-0" Version="3.1.38" />
  </ItemGroup>


Issue 2. Microsoft trace logs appear in the test results in "Trace" cell for some of the scenario steps, making test almost unusable.

TraceLogsIssue.jpg



















I tried setting up appsettings.json, 

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Trace",
      "System": "Information",
      "Microsoft": "None"

or adding Serilog NuGet with settings (Btw, the project doesn't have startup.cs or program.cs, so I'm not sure where to set up to use Serilog settings) :

"Serilog": {
  "MinimumLevel": {
    "Default": "Verbose",
    "Override": {
      "Microsoft": "Error",
      "System": "Error"
    }

or Environment variable:

Logging:LogLevel:Microsoft=None

or specflow.json:

{
  "Trace": {
    "traceSuccessfulSteps": "false"
  }
}


But no effect.


Issue 3. Test do run, but sometimes I have a strange info-message in VS Test Output log:

StreamJsonRpc.RemoteInvocationException: The following TestContainer was not found 'C:\Repos\....\bin\Debug\netcoreapp3.1\....Tests.dll' at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__96`1.MoveNext()

I don't know how 3.1 coming here, since project is 2.1,


Issue 4. JavaScript warnings and errors are not available. Which is a known issue, and has a reason:


But any workarounds for that?
I tried Selenium.WebDriver 4.0 alpha, but did not work.


Issue 5. This is not really an issue. I'm experimenting with the built-in DI (BoDi) and for me it's a bit strange that I have to add all dependent classes one-by-one to the constructor or add IObjectContainer parameter and resolve them.

public LoginPage(IObjectContainer objectContainer)
 {
  if (objectContainer == null) throw new ArgumentNullException(nameof(objectContainer));

  m_WebDriver = objectContainer.Resolve<IWebDriver>()
  ....
.
Isn't there some static object to ask for resolving without adding constructor parameters?

Thank you.

Stephen McCafferty

unread,
Jan 20, 2020, 9:27:52 AM1/20/20
to SpecRun
1) There's no easy way around this unfortunately; my experience has been that the best way to edit the templates is to do it bit by bit, so that if you have any errors, you know where they are. The error messages do not include the correct line numbers, which makes finding the correct location nigh on impossible. So instead, I have taken to writing a short section, testing it, and then moving on. That means that if there is an error, it is clear where the problem is (the part I just edited), and that makes finding the bug much, much easier.

We hope to implement a new reporting mechanism at some point in the future that will eliminate these issues.

2) This looks like a bug in SpecFlow that we need to fix.

3) This is very strange. Do you have a project you can share that reproduces this issue (even if it is only sporadic)?

4) We are unfortunately not aware of a workaround. Have you tried contacting the Selenium team?

5) There is no option to use a static object, as this would cause big problems with parallel execution (the different threads would be accessing the same object if it were static).
Reply all
Reply to author
Forward
0 new messages