Using Rubberduck's unit tests, how can I find out which of several statements failed?

I use Rubberduck to unit test my VBA implementations. When using multiple statements of the same type (for example Assert.IsTrue) in the same TestMethod method, the test result does not tell me which one failed, as far as I can see.

Is there any way to find out which Assert failed or is it on the future Rubberduck roadmap? Of course, I could add my own information, for example. using Debug.Printin front of each Assert, but this will cause a lot of extra code.

I know that in one test there are different opinions about several Asserts, but I decided to use them in my situation, and this discussion has already been considered elsewhere .

+6
source share
1 answer

Disclaimer: I am actively involved in the development of Rubberduck.

An interface IAssertthat implements both Rubberduck.AssertClass, and Rubberduck.PermissiveAssertClass, includes an optional parameter messagefor each individual member:

Object Browser showing members of 'AssertClass'

Just add a different and descriptive message for each statement:

Assert.AreEqual expected, actual, "oops, didn't expect this"
Assert.IsTrue result, "truth is an illusion"

In the test explorer window, a custom message will be displayed in the "Message" column only if the approval is not completed:

RD Test Explorer

+5

Source: https://habr.com/ru/post/1016366/


All Articles