You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Changing DefaultFloatingPointTolerance breaks tests running in parallel #1918
GlobalSettings.DefaultFloatingPointTolerance is a static. When it is changed for a single test, other tests may be affected. Even if the test resets it to the original value in TearDown, any tests that run in parallel with the test making the change are affected.
We should deprecate the GlobalSettings class (this is its sole member) and provide some other way to change the default tolerance. As it stands, the default tolerance should only be set at the command-line or in a global SetUpFixture.
PR #1950 does a temporary fix for our own tests but this remains open to deal with removing (first deprecating) GlobalSettings and creating an alternative way to change the default for a test. This will most likely be a thread-based setting in the TestExecutionContext.
I'm removing my assignment, in case somebody else wants to take this on after the release.
What did you see the user API to this looking like, @CharliePoole? Just a command line option/FrameworkPackageSetting? Should there be a way to set it per test?
I'm tempted to just go command line option, until people ask for more.
It's already a command-line option and package setting. But that's the default. What happens when a fixture or method wants to work with a different default? One approach is to just make the global settings obsolete and have users specify any non-default tolerance on each assertion. Another would be to define an attribute that implements IApplyToContext and sets the context default to a different value.
IIRC, once you get the value into the execution context it will be used automagically. That needs to be checked. The good thing is that if you set it on a class, it will apply just for the tests in that class and if you set it on a method it will only apply for that method.
I'm not sure how important this is. In fact, we only use it in tests that test the feature itself. 😄 But it would be worth cleaning up if only to get those tests of ours to run in parallel.
It's already a command-line option and package setting.
Is it? I don't see either, am I missing something?
One approach is to just make the global settings obsolete and have users specify any non-default tolerance on each assertion.
I'd be tempted to go with this, up until we find out someone needs something more general. 😄 I was seeing this just as an issue to tidy up something a bit buggy.
The command-line option is --timeout, which sets FrameworkPackageSettings.PackageSettings.
To just tidy it, you would have to figure out a way to make our tests work - maybe just set the context directly in the test itself and let it get cleaned up on exit from the context.
This is floating point tolerance, rather than timeout. ;-) I don't think there is an existing packagesetting, just the global?
Thinking this through - this feels like something that people will want to define when the tests are authored, rather than runtime? Meaning maybe just replacing it with an attribute which can be applied at any level is the best course of action? This would also be the closest match to the current global functionality.
An attribute is a good approach, as you suggest. I think you will have to add this to the execution context with an initial value of zero on the default constructor, copying the value in the constructor that takes another context and referring to the current context in place of GlobalSettings.
I have it half done, but never got back to finishing it, with working on xamarin and templates. Im away for the next week - please feel free to take it, if you fancy it!
Activity
CharliePoole commentedon Jan 3, 2017
This keeps breaking the build. I'm going to put in a temporary fix, at least.
CharliePoole commentedon Jan 4, 2017
PR #1950 does a temporary fix for our own tests but this remains open to deal with removing (first deprecating) GlobalSettings and creating an alternative way to change the default for a test. This will most likely be a thread-based setting in the TestExecutionContext.
I'm removing my assignment, in case somebody else wants to take this on after the release.
ChrisMaddock commentedon Jan 28, 2017
What did you see the user API to this looking like, @CharliePoole? Just a command line option/FrameworkPackageSetting? Should there be a way to set it per test?
I'm tempted to just go command line option, until people ask for more.
CharliePoole commentedon Jan 28, 2017
It's already a command-line option and package setting. But that's the default. What happens when a fixture or method wants to work with a different default? One approach is to just make the global settings obsolete and have users specify any non-default tolerance on each assertion. Another would be to define an attribute that implements IApplyToContext and sets the context default to a different value.
IIRC, once you get the value into the execution context it will be used automagically. That needs to be checked. The good thing is that if you set it on a class, it will apply just for the tests in that class and if you set it on a method it will only apply for that method.
I'm not sure how important this is. In fact, we only use it in tests that test the feature itself. 😄 But it would be worth cleaning up if only to get those tests of ours to run in parallel.
ChrisMaddock commentedon Jan 28, 2017
Is it? I don't see either, am I missing something?
I'd be tempted to go with this, up until we find out someone needs something more general. 😄 I was seeing this just as an issue to tidy up something a bit buggy.
CharliePoole commentedon Jan 28, 2017
The command-line option is
--timeout, which setsFrameworkPackageSettings.PackageSettings.To just tidy it, you would have to figure out a way to make our tests work - maybe just set the context directly in the test itself and let it get cleaned up on exit from the context.
ChrisMaddock commentedon Jan 28, 2017
This is floating point tolerance, rather than timeout. ;-) I don't think there is an existing packagesetting, just the global?
Thinking this through - this feels like something that people will want to define when the tests are authored, rather than runtime? Meaning maybe just replacing it with an attribute which can be applied at any level is the best course of action? This would also be the closest match to the current global functionality.
CharliePoole commentedon Jan 28, 2017
Sorry... I got my discussions crossed!
An attribute is a good approach, as you suggest. I think you will have to add this to the execution context with an initial value of zero on the default constructor, copying the value in the constructor that takes another context and referring to the current context in place of GlobalSettings.
CharliePoole commentedon Apr 14, 2017
@ChrisMaddock Anything going on this? It has been a while since you took it.
ChrisMaddock commentedon Apr 14, 2017
I have it half done, but never got back to finishing it, with working on xamarin and templates. Im away for the next week - please feel free to take it, if you fancy it!