You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/12/22 17:22:50 UTC
[GitHub] [netbeans] lbownik commented on a diff in pull request #5061: rewritten 2 tests of org.openide.util.TaskTest into more readable form
lbownik commented on code in PR #5061:
URL: https://github.com/apache/netbeans/pull/5061#discussion_r1055684470
##########
platform/openide.util/test/unit/src/org/openide/util/TaskTest.java:
##########
@@ -260,26 +303,32 @@ public void testWaitWithTimeOutReturnsAfterTimeOutWhenTheTaskIsNotComputedAtAll
fail ("Something wrong happened the task should wait for 1000ms but it took: " + time + "\n" + log);
}
+
+ //--------------------------------------------------------------------------
@Test
- public void testWaitOnStrangeTaskThatStartsItsExecutionInOverridenWaitFinishedMethodLikeFolderInstancesDo () throws Exception {
+ public void waitOnTask_thatStartsItsExecutionWithOverridenWaitFinishedMethod()
+ throws Exception { // like FolderInstances do
+
class MyTask extends Task {
- private int values;
-
- public MyTask () {
- notifyFinished ();
+
+ private int values = 0;
+
+ public MyTask() {
+ notifyFinished();
}
-
- public void waitFinished () {
- notifyRunning ();
+
+ @Override
+ public void waitFinished() {
+ notifyRunning();
values++;
- notifyFinished ();
+ notifyFinished();
}
}
-
- MyTask my = new MyTask ();
- assertTrue ("The task thinks that he is finished", my.isFinished ());
- assertTrue ("Ok, even with timeout we got the result", my.waitFinished (1000));
- assertEquals ("But the old waitFinished is called", 1, my.values);
+
+ MyTask my = new MyTask();
+ assertTrue(my.isFinished()); //The task thinks that he is finished.
Review Comment:
I'm confused - when the test fails just looking at this line makes is obvious what went wrong
Original messages in lines 280-282 were obviously wrong as according to https://junit.org/junit4/javadoc/4.13/org/junit/Assert.html#assertTrue(java.lang.String,%20boolean)
they get displayed only if the assertion fails.
could You propose an example?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists