Skip to content
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

#104 Fix test instability related to timers #105

Merged
merged 2 commits into from
Dec 8, 2024

Conversation

wjgerritsen-0001
Copy link
Contributor

use global usings to reduce the number of usings in each file
upgrade to NUnit 4 and use Assert.That syntax everywhere added constraints to verify (no) timeout: Does.Timeout and Does.NoTimeout

  • verify exception throwed
  • verfiy error message
  • verify duration Refactored outcommented test to use [Ignore] attribute Single place to read resource path from assembly: BaseTest.EmptyHtmlPath

upgrade to NUnit 4 and use Assert.That syntax everywhere
added constraints to verify (no) timeout: Does.Timeout and Does.NoTimeout
- verify exception throwed
- verfiy error message
- verify duration
Refactored outcommented test to use [Ignore] attribute
Single place to read resource path from assembly: BaseTest.EmptyHtmlPath
}

var elapsedTime = DateTime.Now.Subtract(beforeCall);
return new ConstraintResult(this, elapsedTime, elapsedTime < maximumDelay && elapsedTime >= (minimumDelay ?? TimeSpan.Zero));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably most people will naturally read "maximum" as "maximum possible", i.e. "inclusive the maximum as a valid value among the range"... Probably would be better then to use <= over <...

return new ConstraintResult(this, elapsedTime, elapsedTime < maximumDelay && elapsedTime >= (minimumDelay ?? TimeSpan.Zero));
}

public override string Description => $"Should not timeout" + (minimumDelay.HasValue ? $" or pass in less then {minimumDelay}" : "");
Copy link
Owner

@yashaka yashaka Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we mention tyhe maximumDelay value in tyhe description too?
I propose the following error message:

       public override string Description => $"Should not timeout" + (minimumDelay.HasValue ? $" and pass within: {minimumDelay} < delay <= {maximumDelay}" : "");

If the actual comparison was tuned to <= then description should be tuned correspondingly...

internal class TimeoutConstraint(string errorMessage) : Constraint
{
private readonly string errorMessage = $$"""
Timed out after {{Configuration.Timeout}}s, while waiting for:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh:) Tightly coupled to the "global variable" that is also might be not obvious from the usage:)
the accuracyDelta below is also kind of "hardcoded"... I would at least inject these values as dependencies, then use same defaults, but at least having an option to parametrize if needed...
But OK, we can keep it as it is for now... and later I can rafactor these things for this constraint...

@yashaka
Copy link
Owner

yashaka commented Dec 8, 2024

Hm, let me actually do small adjustments mentioned above on my own and finalize this PR...

@yashaka yashaka merged commit 54b05b9 into yashaka:master Dec 8, 2024
1 check passed
@yashaka
Copy link
Owner

yashaka commented Dec 8, 2024

@wjgerritsen-0001 Thank you so much for so enormous efforts! Great job!

@wjgerritsen-0001 wjgerritsen-0001 deleted the refactor_timeout_testing branch February 4, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants