From 942605c49b1f24ba4bc3a9b585ba4b15436eb02f Mon Sep 17 00:00:00 2001 From: Krishnan Mahadevan Date: Thu, 21 Mar 2024 14:32:53 +0530 Subject: [PATCH] Fixing flaky tests --- .../test/listeners/issue2916/ElaborateSampleTestCase.java | 5 +++-- .../test/java/test/thread/issue188/Issue188TestSample.java | 2 +- .../src/test/java/org/testng/test/osgi/PlainOsgiTest.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/testng-core/src/test/java/test/listeners/issue2916/ElaborateSampleTestCase.java b/testng-core/src/test/java/test/listeners/issue2916/ElaborateSampleTestCase.java index 2a8831ea99..ef0b4c9e7e 100644 --- a/testng-core/src/test/java/test/listeners/issue2916/ElaborateSampleTestCase.java +++ b/testng-core/src/test/java/test/listeners/issue2916/ElaborateSampleTestCase.java @@ -23,8 +23,9 @@ public void flakyTest() { } } - @Test(timeOut = 2, priority = 4) + @Test(timeOut = 25, priority = 4) public void timingOutTest() throws InterruptedException { - TimeUnit.MILLISECONDS.sleep(10); + TimeUnit.SECONDS.sleep(10); + Assert.fail(); } } diff --git a/testng-core/src/test/java/test/thread/issue188/Issue188TestSample.java b/testng-core/src/test/java/test/thread/issue188/Issue188TestSample.java index d19c692b47..23f9b7d760 100644 --- a/testng-core/src/test/java/test/thread/issue188/Issue188TestSample.java +++ b/testng-core/src/test/java/test/thread/issue188/Issue188TestSample.java @@ -37,7 +37,7 @@ public void anotherSampleTest() { private void sleepSilently() { try { - TimeUnit.MILLISECONDS.sleep(500 * random.nextInt(10)); + TimeUnit.MILLISECONDS.sleep(5000 * random.nextInt(5)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } diff --git a/testng-test-osgi/src/test/java/org/testng/test/osgi/PlainOsgiTest.java b/testng-test-osgi/src/test/java/org/testng/test/osgi/PlainOsgiTest.java index 6f8635a695..05033dab2a 100644 --- a/testng-test-osgi/src/test/java/org/testng/test/osgi/PlainOsgiTest.java +++ b/testng-test-osgi/src/test/java/org/testng/test/osgi/PlainOsgiTest.java @@ -25,7 +25,9 @@ public Option[] config() { return options(defaultTestngOsgiOptions()); } - @Test + // TODO: Enable this test once the PR https://github.com/ops4j/org.ops4j.pax.exam2/pull/1112 + // gets merged and there's a new release done. + @Test(enabled = false) public void versionShouldStartWithDigit() throws Exception { Class versionClass = Class.forName("org.testng.internal.Version"); Method getVersionStringMethod = versionClass.getMethod("getVersionString");