consistent test naming for Assert and Observation

Issue #7 open
Adam Ralph
created an issue

When using the {{{Context}}}, {{{Do}}} and {{{Assert}}} methods, on a failing test I get this notification:

//Test 'given a name with whitespace when trimming, the name has no whitespace' failed: Assert.Equal() Failure//

When using the {{{Context}}}, {{{Do}}} and {{{Observation}}} methods, I get this notification:

//Test ' - the name has no whitespace' failed: Assert.Equal() Failure//

Is this desired behaviour? I propose that the test names should be the same in both cases since the latter has missing desired information.

(This was originally raised at SubSpecGWT -

Comments (2)

  1. Johannes Rudolph repo owner
    • changed status to open


    great that you are using SubSpec. The reason the reported behavior in this case is different lies in the way Observations are broken down into their xUnit primitives. A Context, Do, Assert Sequence acts a as a single test, and hence the full test name shows up in the test log.

    A Spec with two Observations would show up as 4 tests in xunit (a bit unintuitive at first but bear with me). The first test entails the setup of the context and do, then follow the observations, and then the context teardown. The advantage of this is that it makes it easier to follow when Observations failed because the context for all of them could not be set up properly.

    As an example:

    "{ Given foo, when we do x
     - Observation1
     - Observation2

    Is 4 different tests and should show up this way in an ordered test log.

  2. Adam Ralph reporter

    Hi Johannes,

    Thanks very much for the explanation, it makes sense.

    Unfortunately, when using, all I get is something like

    Test '	- the name has no whitespace' failed: Expected False, but found True.

    with nothing before it to indicate the context.

    As you say, with a nice ordered test log this wouldn't be a problem since the context would appear above the test, but not so with output. I do, however, get a stack trace beneath the message so at least I can use that to map the message back to the test but obviously it would be far nicer if the context was already sitting there in the output in natural language.

    I haven't really delved into the internals of SubSpec too much but I wonder if there is some way to record the last Context and Do test names and use them when generating the test name for an Observation?

  3. Log in to comment