Can I logging assertions(success and fails) or add assertions to steps? #2242
Replies: 14 comments 13 replies
-
No, FA doesn't have any built-in logging, with the exception of the |
Beta Was this translation helpful? Give feedback.
-
Are you planning to add a handler for adding some decorators in the future? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what you mean. What kind of logging are you trying to collect? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Ah, maybe you can use the |
Beta Was this translation helpful? Give feedback.
-
Can I use it when success assertion? public static Action<AssertionScope, string> AssertionHandler { get; set; }
public void SomeHandler(AssertionScope scope, string description)
{
Console.WriteLine($"Before Assertion: {description}");
scope.ExecuteAssertion();
Console.WriteLine($"After Assertion: {description}");
} |
Beta Was this translation helpful? Give feedback.
-
No, I can't think of a way to do that. It wasn't designed for that purpose. |
Beta Was this translation helpful? Give feedback.
-
Ok, Thanks |
Beta Was this translation helpful? Give feedback.
-
This would really be a great thing to have. Lots of companies are requiring logs/reports for audit purpose and it would be nice to have a way to record pass and failures |
Beta Was this translation helpful? Give feedback.
-
Are there any new plans to introduce such a feature? |
Beta Was this translation helpful? Give feedback.
-
Many people need this functionality, are there any options to implement it? |
Beta Was this translation helpful? Give feedback.
-
There no new plans, the design hasn't changed since:
I'm still not sure what it is that you want to log and where you want to invoke/control this. |
Beta Was this translation helpful? Give feedback.
-
It is my simple example for NUnit. Execute is method which wrap assertion, It should be executed iside fluent assertion framework |
Beta Was this translation helpful? Give feedback.
-
Hi, let me explain my point of view: At the moment I have used FluentAssertions (FA) for writing CI tests unit tests, integration tests, etc executed with MSTest. For this purpose FA is really great and makes writing assertions a lot more convenient. [TestMethod]
public void MyTest()
{
Assert.AreEqual(1, 2);
// vs.
1.Should.Be(2);
} I think it is out of question that FA makes it far more easier to read. At work I am currently maintaining a test framework for testing hard- and software developed by my company. I cannot go into details since the whole system is proprietary but at the end writing test with this system is similar to writing tests with MSTest. There are values (gathered some home how, e.g. from a measurement device) that are checked against expected values. This is done by writing assertions and at the moment they look similar to the methods provided by MSTest. My idea is now to use FA for writing assertions because FA is much more expressive and has far more features (like object comparison, exception checking, etc. and of course very nice default messages). I have already tried to integrate FA into our systems which was not such a big deal but there is one point that is a blocking issue for me: While FA provides very nice failure messages there are no messages in case of success and as far as I see it there is currently no possibility for me to enable them (without forking FA and modifying it the way I need (which is not really an option)). Why is this so important for me?
Proposal Provide an API in FA to enable custom logging of assertion messages. There could be two delegates on for success and one for failure. They should provide the following parameters:
Default behaviour: The current behaviour. |
Beta Was this translation helpful? Give feedback.
-
Description
I would like to log assertions into steps (Allure for example) and other logs. Can I just add a logger or another handler so I don't have to do it for every assertion? Like HttpMessageHandler in HttpClient
Beta Was this translation helpful? Give feedback.
All reactions