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
Spr-17211 - async tests refactoring #1941
Conversation
@antkorwin Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@antkorwin Thank you for signing the Contributor License Agreement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
I've requested a few changes to reduce the noise in this PR.
So let's see how it looks after you've made those changes.
import org.springframework.context.ApplicationContext; | ||
import org.springframework.tests.sample.beans.TestBean; | ||
import org.springframework.util.asyncassert.AsyncAssert; | ||
|
||
import java.util.concurrent.TimeUnit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo all changes to import ordering and use of import wildcards in this PR.
See the following for details: https://github.com/spring-projects/spring-framework/wiki/Code-Style#import-statements
@@ -78,40 +79,35 @@ public void asyncMethods() throws Exception { | |||
try { | |||
asyncTest.returnSomething(0).get(); | |||
fail("Should have thrown ExecutionException"); | |||
} | |||
catch (ExecutionException ex) { | |||
} catch (ExecutionException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please undo all removal of newlines before catch
statements.
See the following for details: https://github.com/spring-projects/spring-framework/wiki/Code-Style#braces
* @param unit unit of time | ||
* @return AsyncAssert with new settings of polling. | ||
*/ | ||
public AsyncAssert polling(long amount, TimeUnit unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use java.time.Duration
instead of implementing a custom type.
* @param unit unit of time | ||
* @return AsyncAssert with new settings of timeout | ||
*/ | ||
public AsyncAssert timeout(long amount, TimeUnit unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use java.time.Duration
instead of implementing a custom type.
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created on 23.08.2018. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all such "Created on" JavaDoc entries in this PR.
This has been merged into Thanks |
I fixed the problem with a fragile tests for asynchronous events.
Also I add the AsyncAssert utility for write an asynchronous test with a better performance than test which use a Thread.sleep(1000)
I've a next result for pass of changed tests on my computer:
before ~30 sec.
after ~12 sec.