-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[dotnet] Future-proof for NUnit 4.x upgrade #14852
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
Comments
@RenderMichael, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Assert.That(...)
NUnit syntax
Thanks, it is good initiative. PS: I edited the goal to be achievable. |
@RenderMichael Will it make sense to create one big PR? I will approve changes like |
@nvborisenko I can make a massive PR, if that's preferable. I'll start adding more changes to #14853 |
If we can agree some rules before big boom. I expect ONLY |
The PR which migrates us to However, there are a few other things which block NUnit 4.x besides that. For example, the |
Assert.That(...)
NUnit syntax
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs. |
Feature and motivation
With the release of NUnit 4.x, a few major breaking changes have been added. We want our test suite to be able to be prepared for NUnit 4, even if we're not going to upgrade for a while yet.
Classic Assert [dotnet] Migrate NUnit assertions to
Assert.That
syntax #14853 [dotnet] Migrate remaining NUnit assertions toAssert.That
andHas.Count
#14870The "classic assert" model has been depreciated. In order to continue using them, the tests would need to jump through some hoops.
A better solution would be to migrate to modern NUnit assertions. The
NUnit.Analyzers
nuget package has useful features to accomplish this. Examples include:Assert.AreEqual("Testing Alerts", driver.Title)
->Assert.That(driver.Title, Is.EqualTo("Testing Alerts"))
Assert.AreEqual(1, allWindows.Count)
->Assert.That(allWindows, Has.One.Items)
String format messages [dotnet] Correct assertion of struct type in internal tests #14878
NUnit 3.x has methods such as
Assert.That(x, Is.EqualTo(y), "Value {0} is {1}", x, y)
. These overloads have been removed, in order to make room for caller argument expression parameters. We will have to go through and turn these all into interpolated strings. Same ForAssert.Ignore(string message, string[] args)
.The handful of uses of
StringAssert
orCollectionAssert
should be changed toAssert.That
. [dotnet] Migrate remaining NUnit assertions toAssert.That
andHas.Count
#14870The text was updated successfully, but these errors were encountered: