bUnit icon indicating copy to clipboard operation
bUnit copied to clipboard

xUnit v3 support / enhancements

Open egil opened this issue 1 year ago • 5 comments

xUnit v3 is out, and while bUnit should work without issues with it, there are new things we may want to address:

  • xUnit now has a TestContext type. See https://xunit.net/docs/getting-started/v3/whats-new#test-context
  • IAssertionException and ITestTimeoutException are new interfaces that we can include in bUnit and mark our assertions exceptions with. See https://xunit.net/docs/getting-started/v3/whats-new#third-party-assertion-library-extension-points

egil avatar Dec 17 '24 09:12 egil

We also might wanna add xunitv3 or similar for our templates

linkdotnet avatar Dec 17 '24 16:12 linkdotnet

Plus we might wanna migrate our testbase sooner or later to v3 (probably something we only wanna do for v2)

linkdotnet avatar Dec 17 '24 16:12 linkdotnet

IAssertionException and ITestTimeoutException are new interfaces that we can include in bUnit and mark our assertions exceptions with. See https://xunit.net/docs/getting-started/v3/whats-new#third-party-assertion-library-extension-points

We would need an abstraction and add this behavior as a 3rd party package, not? Otherwise we are forcing users towards a dependency of xunit.v3?

linkdotnet avatar Dec 17 '24 19:12 linkdotnet

IAssertionException and ITestTimeoutException are new interfaces that we can include in bUnit and mark our assertions exceptions with. See https://xunit.net/docs/getting-started/v3/whats-new#third-party-assertion-library-extension-points

We would need an abstraction and add this behavior as a 3rd party package, not?

Otherwise we are forcing users towards a dependency of xunit.v3?

No we simply create the interfaces in our project, probably as internal. XUnit just matches on the name. We don't need a dependency on xUnit packages.

UPDATE:

The interfaces are not included with xunit at all. There are just logic looking for interfaces with those names.

So the assertion exceptions we throw should implement an internal interface IAssertionException {}, and our WaitFor timeout exception should implement internal interface ITestTimeoutException {}, I think.

egil avatar Dec 17 '24 20:12 egil

We only really have two candidates, in my opinion: ActualExpectedAssertException and WaitForFailedException. The latter one is tricky - as it is used in all WaitForXXX operations. Now, We might want to dissect this into two distinct exceptions that represent the nature of asserting and timeout. Because WaitForElement isn't necessarily an assertion.

All other exceptions like ParameterException, ElementRemovedFromDomException and friends are neither a timeout nor an assertion.

linkdotnet avatar Dec 30 '24 10:12 linkdotnet

We added this to the docs as well as adding the exceptions. Therefore done on v1 and more docs on v2 for xunit.v3

linkdotnet avatar Aug 30 '25 11:08 linkdotnet