[Recent Tests] simplify and rename

This commit is contained in:
Yaroslav Lepenkin
2016-08-10 13:24:46 +03:00
parent e6af0817a6
commit bdfc4d57dd
4 changed files with 46 additions and 48 deletions
@@ -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<String, RunConfigurationEntry>()
private var testsWithoutSuites = arrayListOf<SingleTestInfo>()
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)
@@ -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);
}
}
@@ -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)
@@ -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)