All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.recording.TestRunData Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.recording;

import java.util.*;
import java.util.stream.*;

import org.junit.platform.engine.*;

import net.jqwik.engine.support.*;

public class TestRunData {

	private final Collection data;

	public TestRunData(Collection data) {
		this.data = data;
	}

	public TestRunData() {
		this(new LinkedHashSet<>());
	}

	public void add(TestRun testRun) {
		data.add(testRun);
	}

	public Optional byUniqueId(UniqueId uniqueId) {
		try {
			return data.stream()
					   .filter(testRun -> testRun.hasUniqueId(uniqueId))
					   .findFirst();
		} catch (Throwable t) {
			// An exception during test run data read should not stop the test run.
			// Most of the time it's an error due to format change which will go away
			// after one test run where the test run data has been written anew.
			JqwikExceptionSupport.rethrowIfBlacklisted(t);
			return Optional.empty();
		}
	}

	public Stream allNonSuccessfulTests() {
		return data.stream().filter(TestRun::isNotSuccessful);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy