question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JUnitCore.runClasses() and @Test(timeout)

See original GitHub issue

Hello I have the following code:

public class While {
  public static void whileTrue (){
    while (true) {}
  }
}

import org.junit.Test;
public class WhileTest {
  @Test(timeout = 1000)
  public void testWhileTrue() {
    While.whileTrue();
  }
}

import org.junit.runner.JUnitCore;
public class RunTests {
  public static void main(String[] args) {
    JUnitCore.runClasses(WhileTest.class);
  }
}

By running the main-method I expected, that the test-method terminat after 1000 ms. But nothing terminat. Is this a bug or is there something wrong by using the runClasses-method?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
schlagi123commented, Oct 21, 2015

The extra thread for timed test ist ok, but i expected, that junit kill all created threads when its finished

1reaction
schlagi123commented, Oct 21, 2015

I found out, that the main-thread terminat, but there is a new thread with the test. This thread not terminat.

Read more comments on GitHub >

github_iconTop Results From Across the Web

using runClasses(), JUnit tests not shutting down after timing ...
It seems that a timeout should cause junit to terminate. The test has already failed, why is it still running the code? It...
Read more >
TimeoutTest xref - JUnit 5
1 package org.junit.tests.running.methods; 2 3 import static org.hamcrest. ... 36 @Test 37 public void failureWithTimeout() throws Exception { 38 JUnitCore ...
Read more >
JUnit - Different ways to run tests using JUnitCore - LogicBig
JUnitCore class is very useful to run tests from command line or programmatically. In this tutorial we will go through various ways to...
Read more >
JUnitCore.runClasses - Selenium at Fingertips
In this blogpost, we will learn how to create a Test Suite using JUnit, and execute multiple test cases using JUnit annotations, classes...
Read more >
JUnit JUnitCore Example - HowToDoInJava
JUnit JUnitCore examples to run test classes in seperately one by one or run all tests in one go. Learn to use JUnitCore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found