Search in sources :

Example 11 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class CSVTestReporterService method addScenarioGroupElements.

protected void addScenarioGroupElements(List csv, TestScenarioGroup group, TestScenarioGroup.TestScenarioGroupResource resource, Set categoryNameSet, String actionId, String actionType, boolean isOutputStatus) throws Exception {
    csv.add(group.getScenarioGroupId());
    Iterator categories = categoryNameSet.iterator();
    Map categoryMap = resource == null ? null : resource.getCategoryMap();
    while (categories.hasNext()) {
        String categoryName = (String) categories.next();
        csv.add(categoryMap == null ? null : categoryMap.get(categoryName));
    }
    if (resource != null) {
        csv.add(resource.getTitle());
        csv.add(resource.getDescription());
    } else {
        csv.add(null);
        csv.add(null);
    }
    TestScenarioGroup.Status status = group.getStatus();
    final boolean isNotRun = status == null || status.getState() == TestScenarioGroup.Status.INITIAL;
    if (status == null || !isOutputStatus) {
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
        csv.add(null);
    } else {
        SimpleDateFormat format = new SimpleDateFormat(dateFormat);
        csv.add(status.getUserId());
        csv.add(status.getStartTime() == null ? null : format.format(status.getStartTime()));
        csv.add(status.getEndTime() == null ? null : format.format(status.getEndTime()));
        csv.add(status.getStateString());
        if (isNotRun) {
            csv.add(null);
            csv.add(null);
        } else {
            boolean result = status.getResult();
            if (result) {
                csv.add("OK");
                csv.add(null);
            } else {
                if (status.getThrowable() == null) {
                    csv.add("NG");
                    csv.add(null);
                } else {
                    csv.add("ERROR");
                    csv.add(toStackTraceString(status.getThrowable()));
                }
            }
        }
    }
    csv.add(actionId);
    if (actionId == null) {
        csv.add(null);
        csv.add(null);
    } else {
        csv.add(resource.getActionTitle(actionId));
        csv.add(resource.getActionDescription(actionId));
    }
    csv.add(actionType);
    if (status == null || isNotRun) {
        csv.add(null);
        csv.add(null);
    } else {
        if (actionId == null) {
            csv.add(null);
            csv.add(toStackTraceString(status.getThrowable()));
        } else {
            boolean actionResult = status.getActionResult(actionId);
            if (actionResult) {
                csv.add("OK");
                csv.add(null);
            } else {
                if (status.getThrowable() == null) {
                    csv.add("NG");
                    csv.add(null);
                } else {
                    if (actionId.equals(status.getCurrentActionId())) {
                        csv.add("ERROR");
                        csv.add(toStackTraceString(status.getThrowable()));
                    } else {
                        csv.add(null);
                        csv.add(null);
                    }
                }
            }
        }
    }
}
Also used : TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) Iterator(java.util.Iterator) Map(java.util.Map) SimpleDateFormat(java.text.SimpleDateFormat)

Example 12 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class ConsoleTestReporterService method report.

public void report(TestController controller) {
    TestResult result = new TestResult();
    try {
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.Status groupStatus = groups[i].getStatus();
            if (groupStatus == null) {
                continue;
            }
            Date startTime = groupStatus.getStartTime();
            if (startTime == null) {
                continue;
            }
            ScenarioGroupResult scenarioGroupResult = new ScenarioGroupResult(groups[i]);
            result.add(scenarioGroupResult);
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.Status scenarioStatus = scenarios[j].getStatus();
                if (scenarioStatus == null) {
                    continue;
                }
                startTime = scenarioStatus.getStartTime();
                if (startTime == null) {
                    continue;
                }
                ScenarioResult scenarioResult = new ScenarioResult(scenarios[j]);
                scenarioGroupResult.add(scenarioResult);
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.Status testcaseStatus = testcases[k].getStatus();
                    if (testcaseStatus == null) {
                        continue;
                    }
                    startTime = testcaseStatus.getStartTime();
                    if (startTime == null) {
                        continue;
                    }
                    TestCaseResult testCaseResult = new TestCaseResult(testcases[k]);
                    scenarioResult.add(testCaseResult);
                }
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    }
    System.out.println(result);
    Iterator groupItr = result.scenarioGroupResultMap.values().iterator();
    while (groupItr.hasNext()) {
        ScenarioGroupResult group = (ScenarioGroupResult) groupItr.next();
        System.out.println();
        System.out.println(group.toString());
        System.out.println(group.toSummuryString());
        Iterator scenarios = group.scenarioResultMap.values().iterator();
        while (scenarios.hasNext()) {
            ScenarioResult scenario = (ScenarioResult) scenarios.next();
            System.out.println();
            System.out.println("\t" + scenario.toString());
            System.out.println("\t" + scenario.toSummuryString());
            Iterator testcases = scenario.testcaseResultMap.values().iterator();
            while (testcases.hasNext()) {
                TestCaseResult testcase = (TestCaseResult) testcases.next();
                System.out.println();
                System.out.println("\t\t" + testcase.toString());
            }
        }
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) Date(java.util.Date) TestCase(jp.ossc.nimbus.service.test.TestCase) Iterator(java.util.Iterator)

Example 13 with TestScenarioGroup

use of jp.ossc.nimbus.service.test.TestScenarioGroup in project nimbus by nimbus-org.

the class HtmlTestReporterService method report.

public void report(TestController controller) {
    PrintWriter pw = null;
    try {
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        pw = new PrintWriter(new BufferedWriter(new FileWriter(new File(outputPath, "index.html"))));
        pw.println("<html>");
        pw.println("<head><title>Test Result</title></head>");
        pw.println("<body>");
        pw.println("<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\" width=\"70%\">");
        pw.println("<tr bgcolor=\"#cccccc\">");
        pw.println("<th colspan=\"4\" scope=\"colgroup\">ScenarioGroup</th>");
        pw.println("<th colspan=\"6\" scope=\"colgroup\">Scenario</th>");
        pw.println("<th colspan=\"6\" scope=\"colgroup\">TestCase</th>");
        pw.println("</tr>");
        pw.println("<tr bgcolor=\"#cccccc\">");
        pw.println("<th scope=\"col\">ID</th>");
        pw.println("<th scope=\"col\">実行者</th>");
        pw.println("<th scope=\"col\">開始時間</th>");
        pw.println("<th scope=\"col\">結果</th>");
        pw.println("<th scope=\"col\">ID</th>");
        pw.println("<th scope=\"col\">実行者</th>");
        pw.println("<th scope=\"col\">開始時間</th>");
        pw.println("<th scope=\"col\">終了時間</th>");
        pw.println("<th scope=\"col\">ステータス</th>");
        pw.println("<th scope=\"col\">結果</th>");
        pw.println("<th scope=\"col\">ID</th>");
        pw.println("<th scope=\"col\">実行者</th>");
        pw.println("<th scope=\"col\">開始時間</th>");
        pw.println("<th scope=\"col\">終了時間</th>");
        pw.println("<th scope=\"col\">ステータス</th>");
        pw.println("<th scope=\"col\">結果</th>");
        pw.println("</tr>");
        for (int index = 0; index < groups.length; index++) {
            if (groups[index].getStatus() == null) {
                continue;
            }
            TestScenarioGroup.TestScenarioGroupResource resource = groups[index].getTestScenarioGroupResource();
            if (resource != null) {
                reportScenarioGroup(pw, controller, groups[index]);
            }
        }
        pw.println("</body>");
        pw.println("</html>");
        pw.flush();
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
}
Also used : TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) FileWriter(java.io.FileWriter) File(java.io.File) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

TestScenarioGroup (jp.ossc.nimbus.service.test.TestScenarioGroup)13 TestScenario (jp.ossc.nimbus.service.test.TestScenario)8 TestCase (jp.ossc.nimbus.service.test.TestCase)5 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 IOException (java.io.IOException)4 PrintWriter (java.io.PrintWriter)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1