Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Implement custom versions of 'test000, test001, etc.' #181

Open
tomleightonstars opened this issue Mar 3, 2021 · 9 comments

Comments

@tomleightonstars
Copy link

tomleightonstars commented Mar 3, 2021

Hi, me again! I hope you're well!

I'm just wondering if there's a way to implement a custom version of the SelectorString value in NativeScenario.swift? I'm aware I can change the value in there but then it won't be iterated through git to others.

I know similar is done when parsing the location of the Features folder, so maybe something similar could be done?

I can see 'test' is required in the returned name for the tests to actually run, it would be great to then be able to have something custom after that, if anything, e.g.:
testAScenarioName
test_AScenarioName
test-AScenarioName

❤️

@bbe02
Copy link

bbe02 commented Mar 9, 2021

Thanks @tomleightonstars raising this. It will be a great help if we can do the above.

@deanWombourne
Copy link
Contributor

Hey.

Couple of question to see if I've understood your requirements :)

  1. Do you want to replace the 001, 002 etc i.e. test001TestAFunnyThing could become testHELLOTestAFunnyThing?
  2. Do you want to replace / insert a fixed string, or would you want to insert a string based on information about the test i.e. the index, the name etc?

@tomleightonstars
Copy link
Author

tomleightonstars commented Mar 11, 2021

  1. Yes exactly that
  2. Just a fixed string would be perfect for me, although I could see maybe FeatureName being useful to others

Thank you for all your hard work with this repo 😄❤️

@tomleightonstars
Copy link
Author

Or, would it even possible to remove 'test' as well?

@kerrmarin
Copy link
Member

IIRC we added the numbers to make sure that tests were run sequentially as defined, because the order wasn't guaranteed when the tests were dynamic...?

@bbe02
Copy link

bbe02 commented Mar 11, 2021

I would be against the idea of running tests in some order as each test should be independent. The test name should be unique and should not contain static prefixes.

@deanWombourne
Copy link
Contributor

deanWombourne commented Mar 11, 2021

Personally, so would I. However, a guiding principle I've been following is "do what cucumber would do" and (I believe) it will run the tests in the order they are specified in the feature file.

That being said, if people want to opt out of that behaviour then that's fine by me :)

My current plan for this is for a user to be able to pass in a block which will return the test selector name - where the default would be this (backwards compatibility is important):

NativeScenario.selectorFactory = { (name: String, index: Int) -> String in
  "\(self.leftPad(index))\(self.name.camelCaseify)"
}

This isn't final - there's probably some tweaking here.

@deanWombourne
Copy link
Contributor

FYI @tomleightonstars The prefix test is what Xcode uses to determine which methods are tests - without it they don't get run.

@tomleightonstars
Copy link
Author

Personally, so would I. However, a guiding principle I've been following is "do what cucumber would do" and (I believe) it will run the tests in the order they are specified in the feature file.

That being said, if people want to opt out of that behaviour then that's fine by me :)

My current plan for this is for a user to be able to pass in a block which will return the test selector name - where the default would be this (backwards compatibility is important):

NativeScenario.selectorFactory = { (name: String, index: Int) -> String in
  "\(self.leftPad(index))\(self.name.camelCaseify)"
}

This isn't final - there's probably some tweaking here.

That sounds like a great plan! I had a go at trying to add something in but I couldn't get it working 🤦‍♂️

FYI @tomleightonstars The prefix test is what Xcode uses to determine which methods are tests - without it they don't get run.

fair enough! I thought that might be the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants