question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Name an assertion/property

See original GitHub issue

As far as I can see, when a test is run the failed message returns the actual and expected values, but there is no name of the property shown.

So if I say

5.Should().Be(10);

It returns “Message: Expected 10, but found 5”, but if you have multiple assertions you have no idea which one failed.

Could you not add a named property to Should or a fluent method like .Named(string name) and then add the name to the output messages. I think this would work well and could look like:

5.Should("some number").Be(10);

5.Should().Named("some number").Be(10) 

would give “some number: Expected 10, but found 5”

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
krajekcommented, Oct 1, 2018

Although I recognize the possible usefulness of the idea, I think by now we have enough tools to help us identify the failed assertion.

  • First of all, there is subject identification. As far as I understand it was not available three years ago.
  • Secondly, there is the because parameter?
  • Lastly, unit test runners automatically point you to the line that threw the exception.

@mika76 Would you agree that adding functionality you described would bring little gain in some very specific cases? In that case, you could close the issue.

0reactions
mika76commented, Oct 2, 2018

@krajek it seems subject does exactly what I originally wanted. This is great! Will close.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SystemVerilog Assertions Tutorial
In SystemVerilog there are two kinds of assertions: immediate (assert) and concurrent (assert property). · Immediate assertions are procedural statements and are ...
Read more >
SystemVerilog Assertions
The behavior of a system can be written as an assertion that should be true at all times. Hence assertions are used to...
Read more >
SystemVerilog Assertions Basics
SystemVerilog Assertions (SVA) is essentially a language construct which provides a powerful alternate way to write constraints, checkers and cover points ...
Read more >
Using SystemVerilog Assertions in RTL Code
An assertion is an instruction to a verification tool to check a property. Properties can be checked dynamically by simulators such as VCS,...
Read more >
Assertions in SystemVerilog Immediate and Concurrent
An assertion is a check embedded in design or bound to a design unit during the simulation. Warnings or errors are generated on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found