benscabbia/AutoName.xUnit

Test methods should split before numbers as well as after

Closed this issue · 2 comments

I have a method named Hello1World2 which is converted to Hello1 World2. It would be good if it could be split to Hello 1 World 2.

That can certainly be done. I think the simplest solution would be do add a new SplitBy method i.e. SplitByNumber, which (I think) when used with SplitByUppercase it will give you your desired result.

I will experiment with this in next few days, but I'd hopefully have something ready over the weekend in version 1.2. I'll provide more info once I've experimented with a few more scenarios.

v1.2 should do what you need :). For your specific scenario:

// Output: `Hello 1 World 2 `
[NamedFact(SplitBy.Number, JoinWith.SingleSpace)] 
public void Hello1World2 ()
{}

But if you have a number of words grouped together, then you should use this with Uppercase i.e.

// Output: `Hello 1 Planet World 2 `
[NamedFact(SplitBy.Uppercase | SplitBy.Number, JoinWith.SingleSpace)] 
public void Hello1PlanetWorld2 ()
{}

If you do this more than a few times, than I'd suggest creating your own custom attribute.