Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Render array elements in test output #267

Closed
ursenzler opened this issue Sep 3, 2015 · 18 comments
Closed

Render array elements in test output #267

ursenzler opened this issue Sep 3, 2015 · 18 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ursenzler
Copy link
Contributor

When running these tests

    public class Foo
    {
        [Theory]
        [InlineData(new[] { "00:00-06:00" }, new[] { "05:45-10:00" }, new[] { "06:00-10:00" }, 4 * 60)]
        public void Theory(object[] a, object[] b, object[] c, int i)
        {    
        }

        [Scenario]
        [Example(new[] { "00:00-06:00" }, new[] { "05:45-10:00" }, new[] { "06:00-10:00" }, 4 * 60)]
        public void Scenario(object[] a, object[] b, object[] c, int i)
        {
        }
    }

the output looks like

image

Any idea, why the bare xunit test formats the arguments and the xbehave test doesn't?

@ursenzler
Copy link
Contributor Author

btw, when replacing Example with InlineData, there is still no formatting when using xBehave.

@adamralph
Copy link
Owner

Interesting!

xbehave performs it's own rendering of the test names rather than using the rendering in xunit (due to supporting the generation of default values for method params). For the most part, ToString() is called on each argument but I guess xunit must be special casing arrays by calling ToString() for each element and rendering them in a square bracketed CSV. I'm sure we can just replicate this in xbehave easily enough.

@adamralph adamralph changed the title arguments in Example are not formatted in output Render array elements in test output Sep 3, 2015
@adamralph adamralph added enhancement New feature or request 100 - Ready labels Sep 3, 2015
@adamralph
Copy link
Owner

I guess we could also investigate what xunit does with other enumerable types and if there is any other special rendering we could also replicate it and expand the scope of this beyond just arrays.

@ursenzler
Copy link
Contributor Author

@adamralph can you give me a pointer to where the rendering happens? I didn't find it :-(

@ursenzler
Copy link
Contributor Author

thanks. I'll try to integrate the xUnit magic into that method.

@adamralph
Copy link
Owner

Thank you!

On Thu, 3 Sep 2015 at 10:27 Urs Enzler [email protected] wrote:

thanks. I'll try to integrate the xUnit magic into that method.


Reply to this email directly or view it on GitHub
#267 (comment)
.

@adamralph adamralph added taken and removed jump in labels Sep 3, 2015
@ursenzler
Copy link
Contributor Author

@adamralph how can I create a nuget package from the xBehave sources/binaries. Is there something in the repo or do I have to create it myself?

@adamralph
Copy link
Owner

@ursenzler if you build it using Rake it will produce the nugets in artifacts/bin/.

@ursenzler
Copy link
Contributor Author

@adamralph ah, okay.

@adamralph
Copy link
Owner

That usually means the wrong version of albacore is being used. Did you use bundler to install the gems and invoke rake?

@ursenzler
Copy link
Contributor Author

I went through all the steps in the "how to build" again and I can build now. thanks. Had some gem updates.

@ursenzler
Copy link
Contributor Author

Unfortunately, the ArgumentFormatter used in xUnit is internal.

My suggestion:

  1. make a pull request to xUnit to make ArgumentFormatter public
  2. for now, duplicate the code in xBehave.
  3. once the ArgumentFormatter is public, use it and remove duplication.

What do you think?

@ursenzler
Copy link
Contributor Author

Prototype working:
image

@adamralph
Copy link
Owner

@ursenzler looks good!

I think your suggestion makes sense.

@adamralph adamralph self-assigned this Nov 21, 2015
@adamralph adamralph added this to the 2.1 milestone Nov 22, 2015
@adamralph
Copy link
Owner

adamralph commented Apr 27, 2016

So, it is indeed a little embarrassing that this hasn't been released yet. The reason was that 2.1 was always intended to be a release which added support for DNX/CoreCLR/dotnet/whatever-it's-called-this-month, in line with xunit 2.1, to keep the version numbers aligned. That work has been put on hold.

Given that the first xbehave release containing support for that nebulously named platform will be targeting some version of xunit > 2.1 (not to mention that keeping the xbehave and xunit minor version aligned for eternity probably isnt realistic anyway) I'm happy to push out 2.1 immediately, containing this feature. I'll do so ASAP.

/cc @ursenzler

@ursenzler
Copy link
Contributor Author

woohoo!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants