Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to set the Case Name? #210

@mwhelan

Description

@mwhelan

Steps to Reproduce

   public abstract class SpecificationFor<TSut> where TSut : class
   {
       public void RunTest()
       {
           // Runs the Given When Then methods on derived class
       }
   }

   public class SampleSpecification : SpecificationFor<Result>
   {
       public void Given() { }
       public void When() { }
       public void Then() { }
   }

   public class TestConvention : Discovery
   {
       public TestConvention()
       {
           Classes
               .Where(x => x.IsSpecification());

           Methods
               .Where(x => x.Name == "RunTest");
       }
   }

Expected Behavior

Case name in VS Test Explorer etc. to be "Sample Specification"

Actual Behavior

Case name is "RunTest"

I have a base SpecificationFor class that wires up my tests to run Given When Then scenarios, using a class per test. Fixie does a fantastic job of discovering and executing the tests with this simple convention. Naturally, it uses the method name for the test name that displays in various test runners, however it is not great to have all your tests named "RunTest" and I would love to be able to customize the case name so that it uses the class name instead (or have the flexibility to name it anything really).

NUnit and xUnit both have this functionality, but it is quite clunky and not easy to implement (at least for my use case here). It would be so convenient to just be able to define it in the Discovery convention. i.e. here is how to find the test to run and this is the naming convention to apply to it.

I see there is a pull request from 2015 that implements this exact feature. I'm not sure what the status of this feature is and whether it has already been implemented? Can you please recommend how I might achieve what I'm trying to do?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions