Код: Выделить всё
When I do something
My custom logs
-> done ...
Как это сделать добавить журнал в этот выходной файл консоли? Спасибо.
Я добавил Console.Writeline() в свои шаги, и в файл Standard_Console_Output.log ничего не было добавлено.
ISpecFlowOutputHelper никогда не работает. Я следовал инструкциям документа и получил ошибку: System.InvalidOperationException: невозможно разрешить службу для типа «TechTalk.SpecFlow.Infrastructure.ISpecFlowOutputHelper»
Если я сам зарегистрирую ISpecFlowOutputHelper с помощью
Код: Выделить всё
services.AddSingleton();
Мне кажется, что документ Specflow устарел.
Минимальный пример кода
Я использую VS Professional 2022 (64-разрядная версия) 17.12.1 в Windows 10 и с расширением SpecFlow для VS 2022 (версия: 2022.1.91.26832).
Я создал этот пример проекта с расширением SpecFlow, шаблон поддерживает только .NET 6, но я изменил его на 8.0 вручную, отредактировав файл .csproj.
Код: Выделить всё
net8.0
Код: Выделить всё
Feature: Calculator
@experimental
Scenario: Add two numbers
Given the first number is 50
Then the result should be 120
Код: Выделить всё
using TechTalk.SpecFlow;
using System;
using Xunit;
namespace SpecFlowLogTest.StepDefinitions
{
[Binding]
public sealed class CalculatorStepDefinitions
{
[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(int number)
{
Console.WriteLine("The first number is " + number);
Assert.Equal(1, 2); // the Standard_Console_Output.log file is only attached when the test fails
}
[Then("the result should be (.*)")]
public void ThenTheResultShouldBe(int result)
{
//TODO: implement assert (verification) logic
throw new PendingStepException();
}
}
}
Код: Выделить всё
Given the first number is 50
-> error: Assert.Equal() Failure: Values differ
Expected: 1
Actual: 2 (0.0s)
Then the result should be 120
-> skipped because of previous errors
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-pipeline