Make Test names have spaces
🤔 What's changed?
⚡️ What's your motivation?
Currently in Nunit3, all the test names are using the auto-generated function names that contain no spaces. I want the spaces 😊
🏷️ What kind of change is this?
- :book: Documentation (improvements without changing code)
- :bank: Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)
- :bug: Bug fix (non-breaking change which fixes a defect)
- :zap: New feature (non-breaking change which adds new behaviour)
- :boom: Breaking change (incompatible changes to the API)
♻️ Anything particular you want feedback on?
📋 Checklist:
- [ ] I've changed the behaviour of the code
- [ ] I have added/updated tests to cover my changes.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] Users should know about my change
- [ ] I have added an entry to the "[vNext]" section of the CHANGELOG, linking to this pull request & included my GitHub handle to the release contributors list.
This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.
I'm not really sure how I can go about testing this since I have only interacted with the NuGet version OR if this would be better of just as a plugin ( But I have had some trouble with creating a plugin because it doesn't seem to run the code )
Would love any suggestions or help
I don't know either how this could be tested particularly (I will think on it), but two things you could do:
- Check the NUnit version where the setting was introduced (to see if it is compatible with the versions we support)
- Check if using this changes the possibilities of running scenarios filtered with vstest.console.exe (I remember having some problems with that.)
I'm not really sure how I can go about testing this since I have only interacted with the NuGet version
Maybe you could write unit tests? These examples could help: https://github.com/reqnroll/Reqnroll/blob/main/Tests/Reqnroll.GeneratorTests/UnitTestProvider/NUnit3GeneratorProviderTests.cs
@HeathLoganCampbell Do you need help with proceeding this?
FYI
example of the TestName attribute in NUnit 3
[TestCase(12, 3, ExpectedResult = 4, TestName = "Custom test name")]
[TestCase(12, 2, ExpectedResult = 6)]
[TestCase(12, 4, ExpectedResult = 3)]
public int DivideTest(int n, int d)
{
return n / d;
}
docs here: https://docs.nunit.org/articles/nunit/writing-tests/attributes/testcase.html
Note, this will only work on [TestCase] and not [Test] attributes (AKA ROW_ATTR in Reqnroll) - that's also the case for NUnit 4
Yes. I also did a research and found the same what @304NotModified said. This approach does not work for single tests (single scenarios in our case), but only for data-driven tests (scenario outlines). In some places people mention that you can just make a single test as a data-driven test with a single data point, but I did some checks and it confuses some test runners, so that is not an option for us.
This is the related issue at NUnit: https://github.com/nunit/nunit/issues/688. It was closed due to inactivity, but never implemented. ☹️
So I think we cannot proceed with this PR. Close?
Thanks @HeathLoganCampbell for this PR, but as discussed at https://github.com/reqnroll/Reqnroll/pull/463#issuecomment-2963235686, I'm gonna close this one.
If you think that is a mistake, please let me know!