-
Notifications
You must be signed in to change notification settings - Fork 638
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
Make assertions into a 1st class feature in the test framework #306
Comments
Before putting any more work into nunit, I'd recommend giving xunit a go I've always preferred it over nunit (and mstest) |
The Lucene test framework is unique in that it is a component that is meant for use by end users as well as our own tests. I did some research, and I cannot find another example of this on the .NET platform - it is unprecedented. In Java, the test framework uses a custom runner called Randomized Testing that is built on top of JUnit using its extensibility. The framework is inheritance-based, uses its own random seed functionality, and has its own attributes it needs to scan for during the test life cycle. Putting in enough functionality to actually debug the random tests (by outputting the random seed that was used during a failure so it can be plugged back in to debug) is a problem that still hasn't been completely solved yet. I asked the NUnit team, and they don't currently support the extensibility points to build your own test runner. So, in the spirit of not re-inventing the wheel we are trying to make do with only NUnit's features out of the box. Not all of the features of the test framework are supported this way (such as running the tests in a random order), but I believe we have enough of them to get by without our own test runner. NUnit is the only framework that comes close to being able to support an inheritance-based framework without a ton of research and tradeoffs. In case you haven't been following along for the past few years, @conniey worked on converting to xUnit for several months back in 2016-2017 and ultimately came to the conclusion that it wasn't possible. But I believe she was trying to take advantage of xUnit's parallel features. In 2019, we tried converting the test framework to both xUnit and MSTest in addition to NUnit. MSTest was completely impossible to support due to the fact that it doesn't scan for its own attributes in base classes. Maybe that has changed, but it wasn't possible in 2019. xUnit forces you to inject state into the constructor in order to get any control over what would ordinarily be Ultimately, xUnit will be a lot more work to support than NUnit, and the fact that xUnit doesn't support an inheritance-based model that "just works" without forcing end users to override your constructor makes it less desirable than NUnit. So, after over a year of research and trial and err, we determined that:
|
Just an update on our NUnit integration. We added the repeatable randomized testing functionality in #547, so now it is much easier to debug random tests. This was done primarily by implementing our own The We also added We are still missing the The So, we are very much integrated with NUnit at this point, and I am not sure there is another test framework that can support all of this functionality (at least not without making our own fork of it). That said, NUnit 4 has already shipped and it is not yet known how much work is involved with supporting it. |
We recently discovered that the assertions provided by NUnit do not provide any support for primitive types and in those cases will default to
object
which causes boxing/unboxing when doing assertions. This can be a huge drain on performance when this operation is done in a tight loop.It is clear that end users will likely run into similar issues with testing that we did. While we have addressed the problem, we did so in 2 assertions types that are both internal. We need to create a public API for assertions that end users of the test framework can use.
LuceneTestCase
and all of its subclasses needs to be devisedIn Lucene,
LuceneTestCase
simply subclassedAssert
. However, due to a difference in naming conventions between NUnit and JUnit, this would seem odd. For example, instead ofAssertEquals
, the NUnit team named their methodAreEqual
. While this isn't such a problem, it would be inconsistent with all of the other custom assertions in the test framework (i.e.AssertAnalyzesTo
).In addition, API documentation should be provided for each of the assertions.
The text was updated successfully, but these errors were encountered: