Search in sources :

Example 6 with TestScenario

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

the class ScenarioTestView method setupStatusLabel.

/**
 * 実行中のシナリオグループ、シナリオ、テストケースをラベルに設定する。
 * @throws Exception
 */
private void setupStatusLabel() throws Exception {
    TestScenarioGroup group = testController.getCurrentScenarioGroup();
    TestScenario scenario = testController.getCurrentScenario();
    TestCase testcase = testController.getCurrentTestCase();
    StringBuilder sb = new StringBuilder();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm");
    if (group != null) {
        sb.append("ScenarioGroup=" + group.getScenarioGroupId());
        if (group.getStatus() != null) {
            sb.append("(" + group.getStatus().getUserId());
            if (group.getStatus().getStartTime() != null) {
                sb.append(" " + sdf.format(group.getStatus().getStartTime()));
            }
            sb.append(")");
        }
        if (scenario != null) {
            sb.append(", Scenario=" + scenario.getScenarioId());
            if (scenario.getStatus() != null) {
                sb.append("(" + scenario.getStatus().getUserId());
                if (scenario.getStatus().getStartTime() != null) {
                    sb.append(" " + sdf.format(scenario.getStatus().getStartTime()));
                }
                sb.append(")");
            }
            if (testcase != null) {
                sb.append(", Testcase=" + testcase.getTestCaseId());
                if (testcase.getStatus() != null) {
                    sb.append("(" + testcase.getStatus().getUserId());
                    if (testcase.getStatus().getStartTime() != null) {
                        sb.append(" " + sdf.format(testcase.getStatus().getStartTime()));
                    }
                    sb.append(")");
                }
            }
        }
    } else {
        sb.append("無し");
    }
    this.statusLabel2.setText(sb.toString());
    this.statusLabel2.setToolTipText(sb.toString());
}
Also used : TestCase(jp.ossc.nimbus.service.test.TestCase) TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with TestScenario

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

the class ScenarioTestView method setupScenarioComponents.

/**
 * シナリオ系コンポーネントの設定
 * @throws Exception
 */
private void setupScenarioComponents() throws Exception {
    TestScenarioGroup currentScenarioGroup = testController.getCurrentScenarioGroup();
    if (currentScenarioGroup == null) {
        this.scenarioGroupStartButton.setEnabled(true);
        this.scenarioGroupEndButton.setEnabled(false);
        this.scenarioCombobox.setEnabled(false);
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
        return;
    } else {
        this.scenarioGroupStartButton.setEnabled(false);
        this.scenarioGroupEndButton.setEnabled(true);
    }
    String currentScenarioGroupId = currentScenarioGroup.getScenarioGroupId();
    if (this.scenarioCombobox.getSelectedItem() == null)
        return;
    String selectScenarioId = this.scenarioCombobox.getSelectedItem().toString();
    TestScenario selectSenario = null;
    if (currentScenarioGroupId != null && selectScenarioId != null) {
        selectSenario = testController.getScenario(currentScenarioGroupId, selectScenarioId);
    }
    if (selectSenario == null) {
        return;
    }
    final TestScenario.Status status = selectSenario.getStatus();
    this.scenarioStatusButton.change(status);
    if (status != null && status.getState() == TestScenario.Status.STARTED) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(true);
        this.scenarioCancelButton.setEnabled(true);
        this.scenarioDownloadButton.setEnabled(false);
    } else if (status != null && status.getState() == TestScenario.Status.END) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(true);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(true);
    } else if (status == null || (status != null && (status.getState() == TestScenario.Status.INITIAL || status.getState() == TestScenario.Status.CANCELED || status.getState() == TestScenario.Status.ERROR))) {
        this.scenarioCombobox.setEnabled(true);
        this.scenarioStartButton.setEnabled(true);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
    } else {
        if (this.scenarioCombobox.getItemCount() == 0) {
            this.scenarioCombobox.setEnabled(false);
        } else {
            this.scenarioCombobox.setEnabled(true);
        }
        this.scenarioStartButton.setEnabled(false);
        this.scenarioEndButton.setEnabled(false);
        this.scenarioCancelButton.setEnabled(false);
        this.scenarioDownloadButton.setEnabled(false);
    }
}
Also used : TestScenario(jp.ossc.nimbus.service.test.TestScenario) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup)

Example 8 with TestScenario

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

the class CSVTestReporterService method report.

public void report(TestController controller) {
    CSVWriter writer = csvWriter == null ? new CSVWriter() : csvWriter.cloneWriter();
    if (writer.getNullValue() == null) {
        writer.setNullValue("");
    }
    List csv = new ArrayList();
    try {
        BufferedWriter bw = new BufferedWriter(encoding == null ? new FileWriter(outputFile) : new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
        writer.setWriter(bw);
        Set scenarioGroupCategorySet = new TreeSet();
        Set scenarioCategorySet = new TreeSet();
        Set testcaseCategorySet = new TreeSet();
        TestScenarioGroup[] groups = controller.getScenarioGroups();
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            if (sgr != null) {
                Map categoryMap = sgr.getCategoryMap();
                if (categoryMap.size() != 0) {
                    scenarioGroupCategorySet.addAll(categoryMap.keySet());
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                if (sr != null) {
                    Map categoryMap = sr.getCategoryMap();
                    if (categoryMap.size() != 0) {
                        scenarioCategorySet.addAll(categoryMap.keySet());
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    if (tr != null) {
                        Map categoryMap = tr.getCategoryMap();
                        if (categoryMap.size() != 0) {
                            testcaseCategorySet.addAll(categoryMap.keySet());
                        }
                    }
                }
            }
        }
        csv.add("ScenarioGroupId");
        Iterator categories = scenarioGroupCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ScenarioId");
        categories = scenarioCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        csv.add("TestcaseId");
        categories = testcaseCategorySet.iterator();
        while (categories.hasNext()) {
            String categoryName = (String) categories.next();
            csv.add(categoryName);
        }
        csv.add("Title");
        csv.add("Description");
        csv.add("UserId");
        csv.add("StartTime");
        csv.add("EndTime");
        csv.add("State");
        csv.add("Result");
        csv.add("Exception");
        csv.add("ActionId");
        csv.add("Title");
        csv.add("Description");
        csv.add("ActionType");
        csv.add("Result");
        csv.add("Exception");
        writer.writeCSV(csv);
        for (int i = 0; i < groups.length; i++) {
            TestScenarioGroup.TestScenarioGroupResource sgr = groups[i].getTestScenarioGroupResource();
            csv.clear();
            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, true);
            addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
            writer.writeCSV(csv);
            if (sgr != null) {
                String[] actionIds = sgr.getBeforeActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "before", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
                actionIds = sgr.getFinallyActionIds();
                if (actionIds != null) {
                    for (int j = 0; j < actionIds.length; j++) {
                        csv.clear();
                        addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, actionIds[j], "finally", false);
                        addScenarioElements(csv, null, null, scenarioCategorySet, null, null, false);
                        addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                        writer.writeCSV(csv);
                    }
                }
            }
            TestScenario[] scenarios = controller.getScenarios(groups[i].getScenarioGroupId());
            for (int j = 0; j < scenarios.length; j++) {
                TestScenario.TestScenarioResource sr = scenarios[j].getTestScenarioResource();
                csv.clear();
                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, true);
                addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                writer.writeCSV(csv);
                if (sr != null) {
                    String[] actionIds = sr.getBeforeActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "before", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getAfterActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "after", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                    actionIds = sr.getFinallyActionIds();
                    if (actionIds != null) {
                        for (int k = 0; k < actionIds.length; k++) {
                            csv.clear();
                            addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                            addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, actionIds[k], "finally", false);
                            addTestCaseElements(csv, null, null, testcaseCategorySet, null, null, false);
                            writer.writeCSV(csv);
                        }
                    }
                }
                TestCase[] testcases = controller.getTestCases(groups[i].getScenarioGroupId(), scenarios[j].getScenarioId());
                for (int k = 0; k < testcases.length; k++) {
                    TestCase.TestCaseResource tr = testcases[k].getTestCaseResource();
                    csv.clear();
                    addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                    addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                    addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, null, null, true);
                    writer.writeCSV(csv);
                    if (tr != null) {
                        String[] actionIds = tr.getBeforeActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "before", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "action", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getAfterActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "after", false);
                                writer.writeCSV(csv);
                            }
                        }
                        actionIds = tr.getFinallyActionIds();
                        if (actionIds != null) {
                            for (int l = 0; l < actionIds.length; l++) {
                                csv.clear();
                                addScenarioGroupElements(csv, groups[i], sgr, scenarioGroupCategorySet, null, null, false);
                                addScenarioElements(csv, scenarios[j], sr, scenarioCategorySet, null, null, false);
                                addTestCaseElements(csv, testcases[k], tr, testcaseCategorySet, actionIds[l], "finally", false);
                                writer.writeCSV(csv);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ServiceManagerFactory.getLogger().write("CTR__00001", e);
        return;
    } finally {
        try {
            writer.flush();
        } catch (IOException e) {
        }
        try {
            writer.close();
        } catch (IOException e) {
        }
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) TestScenario(jp.ossc.nimbus.service.test.TestScenario) FileWriter(java.io.FileWriter) TestScenarioGroup(jp.ossc.nimbus.service.test.TestScenarioGroup) ArrayList(java.util.ArrayList) CSVWriter(jp.ossc.nimbus.io.CSVWriter) BufferedWriter(java.io.BufferedWriter) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) IOException(java.io.IOException) TestCase(jp.ossc.nimbus.service.test.TestCase) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) Map(java.util.Map)

Example 9 with TestScenario

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

the class CSVTestReporterService method addScenarioElements.

protected void addScenarioElements(List csv, TestScenario scenario, TestScenario.TestScenarioResource resource, Set categoryNameSet, String actionId, String actionType, boolean isOutputStatus) throws Exception {
    if (scenario == null) {
        csv.add(null);
    } else {
        csv.add(scenario.getScenarioId());
    }
    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);
    }
    TestScenario.Status status = resource == null ? null : scenario.getStatus();
    final boolean isNotRun = status == null || status.getState() == TestScenario.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 (resource == null || 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 : TestScenario(jp.ossc.nimbus.service.test.TestScenario) Iterator(java.util.Iterator) Map(java.util.Map) SimpleDateFormat(java.text.SimpleDateFormat)

Example 10 with TestScenario

use of jp.ossc.nimbus.service.test.TestScenario 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)

Aggregations

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