Skip to content

Changing DefaultFloatingPointTolerance breaks tests running in parallel #1918

Closed

Description

@CharliePoole

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.

Activity

  1. self-assigned this
    on Jan 3, 2017
  2. added this to the 3.6 milestone on Jan 3, 2017
  3. CharliePoole commented on Jan 3, 2017

    @CharliePoole
    MemberAuthor

    This keeps breaking the build. I'm going to put in a temporary fix, at least.

  4. CharliePoole commented on Jan 4, 2017

    @CharliePoole
    MemberAuthor

    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.

  5. removed this from the 3.6 milestone on Jan 4, 2017
  6. removed their assignment
    on Jan 4, 2017
  7. self-assigned this
    on Jan 28, 2017
  8. ChrisMaddock commented on Jan 28, 2017

    @ChrisMaddock
    Contributor

    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.

  9. CharliePoole commented on Jan 28, 2017

    @CharliePoole
    MemberAuthor

    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.

  10. ChrisMaddock commented on Jan 28, 2017

    @ChrisMaddock
    Contributor

    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.

  11. CharliePoole commented on Jan 28, 2017

    @CharliePoole
    MemberAuthor

    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.

  12. ChrisMaddock commented on Jan 28, 2017

    @ChrisMaddock
    Contributor

    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.

  13. CharliePoole commented on Jan 28, 2017

    @CharliePoole
    MemberAuthor

    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.

  14. CharliePoole commented on Apr 14, 2017

    @CharliePoole
    MemberAuthor

    @ChrisMaddock Anything going on this? It has been a while since you took it.

  15. ChrisMaddock commented on Apr 14, 2017

    @ChrisMaddock
    Contributor

    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!

  16. added this to the 3.7 milestone on Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions