TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.53k stars 2.58k forks source link

Making test less flakily fail #1321

Open java-codehunger opened 1 year ago

java-codehunger commented 1 year ago

Description

This test is flakily fails. I run this test many times and it makes assertion fails.

Related Issue

I was running this test many times and it fails. The failure message is.

Failure: java.lang.AssertionError at org.junit.Assert.fail(Assert.java:86) at org.junit.Assert.assertTrue(Assert.java:41) at org.junit.Assert.assertTrue(Assert.java:52) at org.java_websocket.issues.Issue997Test.test_localServer_ServerLocalhost_ClientLocalhost_CheckInactive(Issue997Test.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:750)

Results :

Failed tests: test_localServer_ServerLocalhost_ClientLocalhost_CheckInactive(org.java_websocket.issues.Issue997Test)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Motivation and Context

It will reduce the chances of flaky failure.

How Has This Been Tested?

I run the test in Ubuntu 20 with JDK both 8 and 11.

Types of changes

Checklist: