Skip to content

Failed timeout does not stop user code #1742

@saiema

Description

@saiema

Hello, I didn't find this issue reported.

On JUnit 5 (5.3.1.v20181005-1442) and also in JUnit 4 (4.12.0.v201504281640), when running the test below on eclipse (Version: 2018-12 (4.10.0) Build id: 20181214-0600) on Ubuntu 18.04, the timeout rule fails to stop de test.

    @Rule
    public Timeout globalTimeout = Timeout.millis(1000);

    @Test
    void test() {
	NaughtyList list = new NaughtyList();
        list.add(1);
    }

For the following class

    public class NaughtyList {
	
	public static class NaughtyNode {
		public int value;
		public NaughtyNode next;
	}
	
	private NaughtyNode header;
	
	public NaughtyList() {
		header = new NaughtyNode();
		header.value = Integer.MIN_VALUE;
	}
	
	public void add(int elem) {
		NaughtyNode current = header;
		while(true) {
			current.next = new NaughtyNode();
			current = current.next;
			current.value = elem;
		}
	}

    }

I know that this is an extreme case but I found this issue when doing some mutation testing experiments and some mutants caused an infinite loop on a very simple code that kept creating new objets.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions