Skip to content

NH-3900 - Update to NUnit 3 #508

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

Closed
wants to merge 10 commits into from
Closed

Conversation

ngbrown
Copy link
Contributor

@ngbrown ngbrown commented Sep 11, 2016

This is for NH-3900.

There are a number of breaking changes between NUnit 2.x and NUnit 3.x, so this takes care of all of them.

NUnit 3 is doing more things in parallel, so this is driving some changes. Especially around the use of SetUpFixture in the NHibernate.Test.Linq namespace. Because NUnit 3 doesn't guarantee the order SetUpFixture in relation to tests in other namespaces, I had to separate the NHibernate.Test.Linq namespace into a separate assembly for it to run correctly.

There is not yet a GUI runner for NUnit 3, so the ShowBuildMenu.bat runs the console version with the appropriate command line switches to limit parallel assembly execution.

@samiraguiar
Copy link

samiraguiar commented Oct 20, 2016

There is a GUI runner for version 3:
https://github.com/nunit/nunit-gui

@ngbrown
Copy link
Contributor Author

ngbrown commented Oct 21, 2016

@samiraguiar The GUI for NUnit 3 is very much alpha/preview level of completion. I tried to use it, but it was quite unstable.

In the meantime, both Visual Studio's Test Runner and ReSharper work well with NUnit 3 tests.

@ngbrown ngbrown changed the title NH-3900 - Update to NUnit 3.4.1 NH-3900 - Update to NUnit 3 Oct 22, 2016
@oskarb oskarb added this to the 5.0.0 milestone Oct 29, 2016
@oskarb
Copy link
Member

oskarb commented Dec 4, 2016

When possible, I think it's a good idea to make preparatory commits first, before introducing the changes the make the build or tests fail. To that effect, I've cherry-picked the changes for ExpectedException and Ignore() to master.

If there really is no other way than to move the linq tests to a separate assembly, that's also something that can be done before switching NUnit.

Anything else that can be merged before the actual switch?

@ngbrown
Copy link
Contributor Author

ngbrown commented Dec 4, 2016

@oskarb a lot of the changes were driven by exploration after updating to NUnit 3.x. Now that we know what it takes, I can work on re-ordering the commit sequence so any NUnit 2.x compatible changes get done first. This means things like TestCaseSource needing a static method, the obsolete NUnit contstrains and exception asserts will be able to be applied to the current master.

I tried numerous ways to get the Linq tests to run consistently in the same assembly, but because they have a different setup fixture with a database intended for read-only, it needed to be in a separate assembly so it would run at a different time. Time ordering wasn't intended to be guaranteed between SetUpFixture and tests outside of that namespace, so with NUnit 2.x, it was just luck that it worked.

Another alternative could be dynamically/randomly named databases generated per fixture. This would allow much more parallel testing, but with the static scripts, it seemed like a pretty big tear-up.

@hazzik
Copy link
Member

hazzik commented Dec 5, 2016

I don't see any issues running linq in the same assembly. (UPD: I see now) However, the LinqReadonlyTestsContext was not updated to use [OneTimeSetUp] and [OneTimeTearDown] as it noted here: https://github.com/nunit/docs/wiki/SetUpFixture-Attribute, so it just did not work at all.

@ngbrown
Copy link
Contributor Author

ngbrown commented Dec 5, 2016

@hazzik Ya, sorry about the OneTimeSetUp missing, I lost that change when I re-based/cherry-picked the project split back to NUnit 2.x. I was about to push it to my branch but you had beat me to it.

@hazzik
Copy link
Member

hazzik commented Dec 5, 2016

Here it says, that --workers=0 might solve the issue.

@ngbrown
Copy link
Contributor Author

ngbrown commented Dec 5, 2016

@hazzik I had seen that, but figured that the "still accidentally" meant it wasn't the way to go. It's up to you and @oskarb how, as maintainers, you want to handle this.

@maca88
Copy link
Contributor

maca88 commented Dec 19, 2016

I can confirm that --workers=0 or [assembly: LevelOfParallelism(0)] does solve the problem. Here you can find my port to NUnit 3 without having to split into multiple assemblies.

@hazzik
Copy link
Member

hazzik commented Feb 11, 2017

Hey, @ngbrown I'm going to resemble your PR with [assembly: LevelOfParallelism(0)], NuGet and NUnit 3.6

@hazzik hazzik closed this Feb 11, 2017
@hazzik
Copy link
Member

hazzik commented Feb 11, 2017

Thanks for all the hard work.

See #550

@ngbrown ngbrown deleted the NH-3900 branch May 3, 2017 04:44
@hazzik hazzik removed this from the 5.0 milestone Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants