From bdfc4d57dd532453cfe16a819cfb5943395af524 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Tue, 9 Aug 2016 19:29:58 +0300 Subject: [PATCH] [Recent Tests] simplify and rename --- .../testIntegration/RecentTestsData.kt | 16 +----- .../RecentTestsListProvider.java | 6 ++- .../testIntergration/RecentTestsOrderTest.kt | 18 ++++--- .../testIntergration/RecentTestsTest.kt | 54 ++++++++++--------- 4 files changed, 46 insertions(+), 48 deletions(-) diff --git a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsData.kt b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsData.kt index 92aa0b47bbeb..8d6ee0b7a01e 100644 --- a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsData.kt +++ b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsData.kt @@ -16,26 +16,14 @@ package com.intellij.testIntegration import com.intellij.execution.RunnerAndConfigurationSettings -import com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude import com.intellij.openapi.vfs.VirtualFileManager -import java.util.* class RecentTestsData { private val runConfigurationSuites = hashMapOf() private var testsWithoutSuites = arrayListOf() - fun addSuite(url: String, runDate: Date, runConfiguration: RunnerAndConfigurationSettings) { - val suite = SuiteEntry(url, runDate, runConfiguration) - addRunConfigurationSuite(suite) - } - - fun addTest(url: String, magnitude: Magnitude, runDate: Date, runConfiguration: RunnerAndConfigurationSettings) { - val test = SingleTestEntry(url, runDate, runConfiguration, magnitude) - addRunConfigurationTest(test) - } - - private fun addRunConfigurationSuite(suite: SuiteEntry) { + fun addSuite(suite: SuiteEntry) { moveSuiteTestsToSuite(suite) val id = suite.runConfiguration.uniqueID @@ -66,7 +54,7 @@ class RecentTestsData { testsWithoutSuites = filteredTests } - private fun addRunConfigurationTest(test: SingleTestEntry) { + fun addTest(test: SingleTestEntry) { val suiteEntry = findRunConfigurationSuite(test.url, test.runConfiguration) if (suiteEntry != null) { suiteEntry.addTest(test) diff --git a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java index 25a83e32f785..102fc8ae0334 100644 --- a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java +++ b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java @@ -103,10 +103,12 @@ public class RecentTestsListProvider { } if (TestLocator.isSuite(url)) { - data.addSuite(url, record.date, runConfiguration); + SuiteEntry entry = new SuiteEntry(url, record.date, runConfiguration); + data.addSuite(entry); } else { - data.addTest(url, magnitude, record.date, runConfiguration); + SingleTestEntry entry = new SingleTestEntry(url, record.date, runConfiguration, magnitude); + data.addTest(entry); } } diff --git a/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsOrderTest.kt b/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsOrderTest.kt index 364b10ed3595..66048cf185e1 100644 --- a/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsOrderTest.kt +++ b/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsOrderTest.kt @@ -20,6 +20,8 @@ import com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magni import com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.PASSED_INDEX import com.intellij.testFramework.LightIdeaTestCase import com.intellij.testIntegration.RecentTestsData +import com.intellij.testIntegration.SingleTestEntry +import com.intellij.testIntegration.SuiteEntry import org.assertj.core.api.Assertions.assertThat import java.util.* @@ -37,27 +39,31 @@ class RecentTestsOrderTest: LightIdeaTestCase() { } fun addPassedSuite(suiteUrl: String, date: Date = Date(), runConfiguration: RunnerAndConfigurationSettings = allTests) { - data.addSuite(suiteUrl, date, runConfiguration) + val suite = SuiteEntry(suiteUrl, date, runConfiguration) + data.addSuite(suite) } fun addFailedSuite(suiteUrl: String, date: Date = Date(), runConfiguration: RunnerAndConfigurationSettings = allTests) { - data.addSuite(suiteUrl, date, runConfiguration) + val suite = SuiteEntry(suiteUrl, date, runConfiguration) + data.addSuite(suite) } fun addPassedTest(testUrl: String, date: Date = Date(), runConfiguration: RunnerAndConfigurationSettings = allTests) { - data.addTest(testUrl, PASSED_INDEX, date, runConfiguration) + val test = SingleTestEntry(testUrl, date, runConfiguration, PASSED_INDEX) + data.addTest(test) } fun addFailedTest(testUrl: String, date: Date = Date(), runConfiguration: RunnerAndConfigurationSettings = allTests) { - data.addTest(testUrl, FAILED_INDEX, date, runConfiguration) + val test = SingleTestEntry(testUrl, date, runConfiguration, FAILED_INDEX) + data.addTest(test) } fun `test run configuration with one suite shows only suite`() { val suite = "MySingleTest".suite() val test1 = "MySingleTest.test1".test() - data.addTest(test1, PASSED_INDEX, now, allTests) - data.addSuite(suite, now, allTests) + data.addTest(SingleTestEntry(test1, now, allTests, PASSED_INDEX)) + data.addSuite(SuiteEntry(suite, now, allTests)) val testsToShow = data.getTestsToShow() assertThat(testsToShow).hasSize(1) diff --git a/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsTest.kt b/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsTest.kt index e040860917e4..0ab2c5966a41 100644 --- a/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsTest.kt +++ b/java/java-tests/testSrc/com/intellij/testIntergration/RecentTestsTest.kt @@ -19,10 +19,7 @@ import com.intellij.execution.RunnerAndConfigurationSettings import com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.FAILED_INDEX import com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.PASSED_INDEX import com.intellij.testFramework.LightIdeaTestCase -import com.intellij.testIntegration.RecentTestsData -import com.intellij.testIntegration.RunConfigurationEntry -import com.intellij.testIntegration.SuiteEntry -import com.intellij.testIntegration.TestConfigurationCollector +import com.intellij.testIntegration.* import org.assertj.core.api.Assertions.assertThat import org.mockito.Mockito.`when` import org.mockito.Mockito.mock @@ -52,14 +49,19 @@ class RecentTestsStepTest: LightIdeaTestCase() { } fun `test all tests passed`() { - data.addTest("Test.textXXX".test(), PASSED_INDEX, now, allTests) - data.addSuite("Test".suite(), now, allTests) - data.addSuite("JFSDTest".suite(), now, allTests) - data.addTest("Test.textYYY".test(), PASSED_INDEX, now, allTests) - data.addTest("JFSDTest.testItMakesMeSadToFixIt".test(), PASSED_INDEX, now, allTests) - data.addTest("Test.textZZZ".test(), PASSED_INDEX, now, allTests) - data.addTest("Test.textQQQ".test(), PASSED_INDEX, now, allTests) - data.addTest("JFSDTest.testUnconditionalAlignmentErrorneous".test(), PASSED_INDEX, now, allTests) + + data.addTest(SingleTestEntry("Test.textXXX".test(), now, allTests, PASSED_INDEX)) + + + data.addSuite(SuiteEntry("Test".suite(), now, allTests)) + + data.addSuite(SuiteEntry("JFSDTest".suite(), now, allTests)) + + data.addTest(SingleTestEntry("Test.textYYY".test(), now, allTests, PASSED_INDEX)) + data.addTest(SingleTestEntry("JFSDTest.testItMakesMeSadToFixIt".test(), now, allTests, PASSED_INDEX)) + data.addTest(SingleTestEntry("Test.textZZZ".test(), now, allTests, PASSED_INDEX)) + data.addTest(SingleTestEntry("Test.textQQQ".test(), now, allTests, PASSED_INDEX)) + data.addTest(SingleTestEntry("JFSDTest.testUnconditionalAlignmentErrorneous".test(), now, allTests, PASSED_INDEX)) val tests = data.getTestsToShow() assertThat(tests).hasSize(1) @@ -68,13 +70,13 @@ class RecentTestsStepTest: LightIdeaTestCase() { fun `test if one failed in run configuration show failed suite`() { - data.addSuite("JFSDTest".suite(), now, allTests) - data.addSuite("Test".suite(), now, allTests) + data.addSuite(SuiteEntry("JFSDTest".suite(), now, allTests)) + data.addSuite(SuiteEntry("Test".suite(), now, allTests)) - data.addTest("JFSDTest.testItMakesMeSadToFixIt".test(), FAILED_INDEX, now, allTests) - data.addTest("JFSDTest.testUnconditionalAlignmentErrorneous".test(), PASSED_INDEX, now, allTests) + data.addTest(SingleTestEntry("JFSDTest.testItMakesMeSadToFixIt".test(), now, allTests, FAILED_INDEX)) + data.addTest(SingleTestEntry("JFSDTest.testUnconditionalAlignmentErrorneous".test(), now, allTests, PASSED_INDEX)) - data.addTest("Test.textXXX".test(), PASSED_INDEX, now, allTests) + data.addTest(SingleTestEntry("Test.textXXX".test(), now, allTests, PASSED_INDEX)) val tests = data.getTestsToShow() @@ -86,9 +88,9 @@ class RecentTestsStepTest: LightIdeaTestCase() { fun `test if configuration with single test show failed test`() { - data.addSuite("JFSDTest".suite(), now, allTests) - data.addTest("JFSDTest.testItMakesMeSadToFixIt".test(), FAILED_INDEX, now, allTests) - data.addTest("JFSDTest.testUnconditionalAlignmentErrorneous".test(), PASSED_INDEX, now, allTests) + data.addSuite(SuiteEntry("JFSDTest".suite(), now, allTests)) + data.addTest(SingleTestEntry("JFSDTest.testItMakesMeSadToFixIt".test(), now, allTests, FAILED_INDEX)) + data.addTest(SingleTestEntry("JFSDTest.testUnconditionalAlignmentErrorneous".test(), now, allTests, PASSED_INDEX)) val tests = data.getTestsToShow() assertThat(tests).hasSize(1) @@ -97,16 +99,16 @@ class RecentTestsStepTest: LightIdeaTestCase() { fun `test show test without suite`() { - data.addTest("Test.sssss".test(), FAILED_INDEX, now, allTests) + data.addTest(SingleTestEntry("Test.sssss".test(), now, allTests, FAILED_INDEX)) val testsToShow = data.getTestsToShow() assertThat(testsToShow).hasSize(1) } fun `test additional entries`() { - data.addSuite("Test2".suite(), now, allTests) - data.addSuite("Test".suite(), now, allTests) - data.addTest("Test.sss".test(), FAILED_INDEX, now, allTests) + data.addSuite(SuiteEntry("Test2".suite(), now, allTests)) + data.addSuite(SuiteEntry("Test".suite(), now, allTests)) + data.addTest(SingleTestEntry("Test.sss".test(), now, allTests, FAILED_INDEX)) val tests = data.getTestsToShow() assertThat(tests).hasSize(1) @@ -123,8 +125,8 @@ class RecentTestsStepTest: LightIdeaTestCase() { } fun `test if configuration consists of single test show only configuration`() { - data.addSuite("Test".suite(), now, allTests) - data.addTest("Test.sss".test(), FAILED_INDEX, now, allTests) + data.addSuite(SuiteEntry("Test".suite(), now, allTests)) + data.addTest(SingleTestEntry("Test.sss".test(), now, allTests, FAILED_INDEX)) val tests = data.getTestsToShow() assertThat(tests).hasSize(1)