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

com.teamscale.test_impacted.engine.TestDataWriter Maven / Gradle / Ivy

Go to download

A JUnit 5 engine that handles retrieving impacted tests from Teamscale and organizes their execution

There is a newer version: 34.2.0
Show newest version
package com.teamscale.test_impacted.engine;

import com.teamscale.client.TestDetails;
import com.teamscale.report.ReportUtils;
import com.teamscale.report.testwise.model.TestExecution;
import com.teamscale.test_impacted.commons.LoggerUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/** Class for writing test data to a report directory. */
public class TestDataWriter {

	private static final Logger LOGGER = LoggerUtils.getLogger(TestDataWriter.class);

	private final File reportDirectory;

	public TestDataWriter(File reportDirectory) {
		this.reportDirectory = reportDirectory;
	}

	/** Writes the given test executions to a report file. */
	void dumpTestExecutions(List testExecutions) {
		File file = new File(reportDirectory, "test-execution.json");
		try {
			ReportUtils.writeTestExecutionReport(file, testExecutions);
		} catch (IOException e) {
			LOGGER.log(Level.SEVERE, e, () -> "Error while writing report to file: " + file);
		}
	}

	/** Writes the given test details to a report file. */
	void dumpTestDetails(List testDetails) {
		File file = new File(reportDirectory, "test-list.json");
		try {
			ReportUtils.writeTestListReport(file, new ArrayList<>(testDetails));
		} catch (IOException e) {
			LOGGER.log(Level.SEVERE, e, () -> "Error while writing report to file: " + file);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy