diff --git a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt index 4e3365887c..ca643c84cc 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt @@ -31,6 +31,6 @@ open class DialogFixture( val closeButton get() = button( - byXpath("//div[@class='DialogHeader']//div[@class='JButton']")) + byXpath("//div[@class='DialogRootPane']//div[@class='JButton']")) } \ No newline at end of file diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt index 0fa3cd3ea6..317cd626a6 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt @@ -157,7 +157,7 @@ open class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent) } fun createNewJavaClass(newClassname: String = "Example", - textToClickOn: String = "org.example") { + textToClickOn: String = "Main") { waitProjectIsOpened() expandProjectTree(projectName) with(projectViewTree) { diff --git a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt index aa8b7dc195..52d0fad081 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt @@ -14,8 +14,8 @@ class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent override fun waitProjectIsCreated() { super.waitProjectIsOpened() - waitForIgnoringError (ofSeconds(60)) { - statusTextPanel.hasText { it.text.contains("Gradle sync finished") } + repeat (120) { + inlineProgressTextPanel.isShowing.not() } } @@ -42,7 +42,7 @@ class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent hasText("src").and(hasText("main")).and(hasText("java")) } } - if (hasText("org.example").not()) { + if (hasText("Main").not()) { findText("java").doubleClick() } } diff --git a/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt b/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt index 35aeb34326..0464782fe3 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt @@ -15,7 +15,7 @@ fun TextEditorFixture.typeAdditionFunction(className: String): String { key(KeyEvent.VK_END) enterText("{") enter() - enterText("// UTBot UI ${TEST_RUN_NUMBER} test") + enterText("// Test run ${TEST_RUN_NUMBER}") enter() enterText("return a + b;") } @@ -32,7 +32,7 @@ fun TextEditorFixture.typeDivisionFunction(className: String) : String { key(KeyEvent.VK_END) enterText("{") enter() - enterText("// UTBot UI ${TEST_RUN_NUMBER} test") + enterText("// Test run ${TEST_RUN_NUMBER}") enter() enterText("return a / b;") } diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt index b7c54f2fdf..eee5299898 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt @@ -33,9 +33,6 @@ class CreateProjects : BaseTest() { val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) with(ideaFrame) { waitProjectIsCreated() - if (ideaBuildSystem == IdeaBuildSystem.INTELLIJ) { - createNewPackage("org.example") - } waitFor(Duration.ofSeconds(30)) { !isDumbMode() } diff --git a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt index 97a00c2f35..3d5f7acb87 100644 --- a/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt +++ b/utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt @@ -12,7 +12,6 @@ import org.utbot.data.NEW_PROJECT_NAME_START import org.utbot.pages.* import org.utbot.samples.typeAdditionFunction import org.utbot.samples.typeDivisionFunction -import java.time.Duration.ofMillis import java.time.Duration.ofSeconds class UnitTestBotActionTest : BaseTest() { @@ -20,8 +19,8 @@ class UnitTestBotActionTest : BaseTest() { @ParameterizedTest(name = "Generate tests in {0} project with JDK {1}") @MethodSource("supportedProjectsProvider") @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Positive")) - fun basicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, - remoteRobot: RemoteRobot) : Unit = with(remoteRobot) { + fun checkBasicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, + remoteRobot: RemoteRobot) { val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number remoteRobot.welcomeFrame { findText(createdProjectName).click() @@ -29,28 +28,26 @@ class UnitTestBotActionTest : BaseTest() { val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) with (ideaFrame) { val newClassName = "Arithmetic" - createNewJavaClass(newClassName, "org.example") + createNewJavaClass(newClassName, "Main") val returnsFromTagBody = textEditor().typeDivisionFunction(newClassName) openUTBotDialogFromProjectViewForClass(newClassName) unitTestBotDialog.generateTestsButton.click() waitForIgnoringError (ofSeconds(5)){ inlineProgressTextPanel.isShowing } - waitForIgnoringError(ofSeconds(60), ofMillis(100)) { - inlineProgressTextPanel.hasText("Generate tests: read classes") - } - waitForIgnoringError (ofSeconds(30)){ + waitForIgnoringError (ofSeconds(90)){ inlineProgressTextPanel.hasText("Generate test cases for class $newClassName") } - waitForIgnoringError(ofSeconds(60)) { //Can be changed to 60 for a complex class + waitForIgnoringError(ofSeconds(30)) { utbotNotification.title.hasText("UnitTestBot: unit tests generated successfully") } assertThat(textEditor().editor.text).contains("class ${newClassName}Test") assertThat(textEditor().editor.text).contains("@Test\n") assertThat(textEditor().editor.text).contains("assertEquals(") assertThat(textEditor().editor.text).contains("@utbot.classUnderTest {@link ${newClassName}}") - assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#division(int, int)}") + assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#") assertThat(textEditor().editor.text).contains(returnsFromTagBody) + //ToDo verify how many tests are generated //ToDo verify Problems view and Arithmetic exception on it } } @@ -58,16 +55,16 @@ class UnitTestBotActionTest : BaseTest() { @ParameterizedTest(name = "Check Generate tests button is disabled in {0} project with unsupported JDK {1}") @MethodSource("unsupportedProjectsProvider") @Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Negative")) - fun checkTestGenerationIsUnavailable(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, - remoteRobot: RemoteRobot) : Unit = with(remoteRobot) { + fun checkProjectWithUnsupportedJDK(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion, + remoteRobot: RemoteRobot) { val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number remoteRobot.welcomeFrame { findText(createdProjectName).click() } val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem) - with (ideaFrame) { + return with (ideaFrame) { val newClassName = "Arithmetic" - createNewJavaClass(newClassName, "org.example") + createNewJavaClass(newClassName, "Main") textEditor().typeAdditionFunction(newClassName) openUTBotDialogFromProjectViewForClass(newClassName) assertThat(unitTestBotDialog.generateTestsButton.isEnabled().not())