ru.yandex.qatools.allure.data.io.TestCaseReader Maven / Gradle / Ivy
package ru.yandex.qatools.allure.data.io;
import com.google.inject.Inject;
import ru.yandex.qatools.allure.model.Description;
import ru.yandex.qatools.allure.model.Label;
import ru.yandex.qatools.allure.model.TestCaseResult;
import ru.yandex.qatools.allure.model.TestSuiteResult;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import static ru.yandex.qatools.allure.data.utils.DescriptionUtils.mergeDescriptions;
/**
* @author Dmitry Baev [email protected]
* Date: 09.02.15
*/
public class TestCaseReader implements Reader {
public static final String SUITE_NAME = "suite-name";
public static final String SUITE_TITLE = "suite-title";
private Iterator testSuites;
private Iterator testCases;
private TestSuiteResult currentSuite;
@Inject
public TestCaseReader(Reader suiteResultsReader) {
testSuites = suiteResultsReader.iterator();
}
@Override
public Iterator iterator() {
return new TestCaseResultIterator();
}
private class TestCaseResultIterator implements Iterator {
private boolean nextSuite() {
if ((testCases == null || !testCases.hasNext()) && testSuites.hasNext()) {
currentSuite = testSuites.next();
testCases = currentSuite.getTestCases().iterator();
return true;
}
return false;
}
@Override
public boolean hasNext() {
return testCases != null && testCases.hasNext() || nextSuite() && hasNext();
}
@Override
public TestCaseResult next() {
if (!hasNext()) {
return null;
}
TestCaseResult result = testCases.next();
Set
© 2015 - 2025 Weber Informatics LLC | Privacy Policy