ru.yandex.qatools.allure.data.plugins.XUnitPlugin.groovy Maven / Gradle / Ivy
package ru.yandex.qatools.allure.data.plugins
import org.codehaus.groovy.runtime.InvokerHelper
import ru.yandex.qatools.allure.data.AllureTestCase
import ru.yandex.qatools.allure.data.AllureTestSuite
import ru.yandex.qatools.allure.data.AllureXUnit
import ru.yandex.qatools.allure.data.ReportGenerationException
import ru.yandex.qatools.allure.data.Statistic
import ru.yandex.qatools.allure.data.StatsWidgetItem
import ru.yandex.qatools.allure.data.Time
import ru.yandex.qatools.allure.data.utils.PluginUtils
/**
* @author Dmitry Baev [email protected]
* Date: 06.02.15
*/
@Plugin.Name("xunit")
@Plugin.Priority(500)
class XUnitPlugin extends DefaultTabPlugin implements WithWidget {
@Plugin.Data
def xUnit = new AllureXUnit(time: new Time(start: Long.MAX_VALUE, stop: Long.MIN_VALUE))
private Map testSuites = [:]
@Override
void process(AllureTestCase testCase) {
if (!testCase.status) {
throw new ReportGenerationException("Test case status should not be null")
}
def uid = testCase.suite.uid
if (!testSuites.containsKey(uid)) {
def suite = new AllureTestSuite()
use(InvokerHelper) {
suite.properties = testCase.suite.properties
}
suite.statistic = new Statistic()
suite.time = new Time(start: Long.MAX_VALUE, stop: Long.MIN_VALUE)
testSuites[uid] = suite
xUnit.testSuites.add(suite)
}
def suite = testSuites[uid]
use(PluginUtils) {
suite.statistic.update(testCase.status)
suite.time.update(testCase.time)
suite.getTestCases().add(testCase.toInfo())
xUnit.time.update(testCase.time)
}
}
@Override
Widget getWidget() {
def widget = new StatsWidget(name)
widget.data = xUnit.testSuites
.sort({ a, b -> PluginUtils.cmp(b.statistic, a.statistic) })
.take(10)
.collect({ new StatsWidgetItem(title: it.title, statistic: it.statistic) })
widget
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy