Skip to content

Commit 638f803

Browse files
IntelliJ plugin UI tests correction for debug IDEA 2023.2 (#2531)
* Corrected locators and waiters in IntelliJ robot UI tests (debug IDEA version changed to 2023.2). * A bit more corrections --------- Co-authored-by: Vassiliy Kudryashov <vassiliy.kudryashov@gmail.com>
1 parent 1480d4b commit 638f803

File tree

6 files changed

+18
-24
lines changed

6 files changed

+18
-24
lines changed

utbot-intellij/src/test/kotlin/org/utbot/dialogs/DialogFixture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ open class DialogFixture(
3131

3232
val closeButton
3333
get() = button(
34-
byXpath("//div[@class='DialogHeader']//div[@class='JButton']"))
34+
byXpath("//div[@class='DialogRootPane']//div[@class='JButton']"))
3535

3636
}

utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaFrame.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ open class IdeaFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent)
157157
}
158158

159159
fun createNewJavaClass(newClassname: String = "Example",
160-
textToClickOn: String = "org.example") {
160+
textToClickOn: String = "Main") {
161161
waitProjectIsOpened()
162162
expandProjectTree(projectName)
163163
with(projectViewTree) {

utbot-intellij/src/test/kotlin/org/utbot/pages/IdeaGradleFrame.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent
1414

1515
override fun waitProjectIsCreated() {
1616
super.waitProjectIsOpened()
17-
waitForIgnoringError (ofSeconds(60)) {
18-
statusTextPanel.hasText { it.text.contains("Gradle sync finished") }
17+
repeat (120) {
18+
inlineProgressTextPanel.isShowing.not()
1919
}
2020
}
2121

@@ -42,7 +42,7 @@ class IdeaGradleFrame(remoteRobot: RemoteRobot, remoteComponent: RemoteComponent
4242
hasText("src").and(hasText("main")).and(hasText("java"))
4343
}
4444
}
45-
if (hasText("org.example").not()) {
45+
if (hasText("Main").not()) {
4646
findText("java").doubleClick()
4747
}
4848
}

utbot-intellij/src/test/kotlin/org/utbot/samples/CodeSamples.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fun TextEditorFixture.typeAdditionFunction(className: String): String {
1515
key(KeyEvent.VK_END)
1616
enterText("{")
1717
enter()
18-
enterText("// UTBot UI ${TEST_RUN_NUMBER} test")
18+
enterText("// Test run ${TEST_RUN_NUMBER}")
1919
enter()
2020
enterText("return a + b;")
2121
}
@@ -32,7 +32,7 @@ fun TextEditorFixture.typeDivisionFunction(className: String) : String {
3232
key(KeyEvent.VK_END)
3333
enterText("{")
3434
enter()
35-
enterText("// UTBot UI ${TEST_RUN_NUMBER} test")
35+
enterText("// Test run ${TEST_RUN_NUMBER}")
3636
enter()
3737
enterText("return a / b;")
3838
}

utbot-intellij/src/test/kotlin/org/utbot/tests/CreateProjects.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class CreateProjects : BaseTest() {
3333
val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem)
3434
with(ideaFrame) {
3535
waitProjectIsCreated()
36-
if (ideaBuildSystem == IdeaBuildSystem.INTELLIJ) {
37-
createNewPackage("org.example")
38-
}
3936
waitFor(Duration.ofSeconds(30)) {
4037
!isDumbMode()
4138
}

utbot-intellij/src/test/kotlin/org/utbot/tests/UnitTestBotActionTest.kt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,59 @@ import org.utbot.data.NEW_PROJECT_NAME_START
1212
import org.utbot.pages.*
1313
import org.utbot.samples.typeAdditionFunction
1414
import org.utbot.samples.typeDivisionFunction
15-
import java.time.Duration.ofMillis
1615
import java.time.Duration.ofSeconds
1716

1817
class UnitTestBotActionTest : BaseTest() {
1918

2019
@ParameterizedTest(name = "Generate tests in {0} project with JDK {1}")
2120
@MethodSource("supportedProjectsProvider")
2221
@Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Positive"))
23-
fun basicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion,
24-
remoteRobot: RemoteRobot) : Unit = with(remoteRobot) {
22+
fun checkBasicTestGeneration(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion,
23+
remoteRobot: RemoteRobot) {
2524
val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number
2625
remoteRobot.welcomeFrame {
2726
findText(createdProjectName).click()
2827
}
2928
val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem)
3029
with (ideaFrame) {
3130
val newClassName = "Arithmetic"
32-
createNewJavaClass(newClassName, "org.example")
31+
createNewJavaClass(newClassName, "Main")
3332
val returnsFromTagBody = textEditor().typeDivisionFunction(newClassName)
3433
openUTBotDialogFromProjectViewForClass(newClassName)
3534
unitTestBotDialog.generateTestsButton.click()
3635
waitForIgnoringError (ofSeconds(5)){
3736
inlineProgressTextPanel.isShowing
3837
}
39-
waitForIgnoringError(ofSeconds(60), ofMillis(100)) {
40-
inlineProgressTextPanel.hasText("Generate tests: read classes")
41-
}
42-
waitForIgnoringError (ofSeconds(30)){
38+
waitForIgnoringError (ofSeconds(90)){
4339
inlineProgressTextPanel.hasText("Generate test cases for class $newClassName")
4440
}
45-
waitForIgnoringError(ofSeconds(60)) { //Can be changed to 60 for a complex class
41+
waitForIgnoringError(ofSeconds(30)) {
4642
utbotNotification.title.hasText("UnitTestBot: unit tests generated successfully")
4743
}
4844
assertThat(textEditor().editor.text).contains("class ${newClassName}Test")
4945
assertThat(textEditor().editor.text).contains("@Test\n")
5046
assertThat(textEditor().editor.text).contains("assertEquals(")
5147
assertThat(textEditor().editor.text).contains("@utbot.classUnderTest {@link ${newClassName}}")
52-
assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#division(int, int)}")
48+
assertThat(textEditor().editor.text).contains("@utbot.methodUnderTest {@link ${newClassName}#")
5349
assertThat(textEditor().editor.text).contains(returnsFromTagBody)
50+
//ToDo verify how many tests are generated
5451
//ToDo verify Problems view and Arithmetic exception on it
5552
}
5653
}
5754

5855
@ParameterizedTest(name = "Check Generate tests button is disabled in {0} project with unsupported JDK {1}")
5956
@MethodSource("unsupportedProjectsProvider")
6057
@Tags(Tag("Java"), Tag("UnitTestBot"), Tag("Negative"))
61-
fun checkTestGenerationIsUnavailable(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion,
62-
remoteRobot: RemoteRobot) : Unit = with(remoteRobot) {
58+
fun checkProjectWithUnsupportedJDK(ideaBuildSystem: IdeaBuildSystem, jdkVersion: JDKVersion,
59+
remoteRobot: RemoteRobot) {
6360
val createdProjectName = NEW_PROJECT_NAME_START + ideaBuildSystem.system + jdkVersion.number
6461
remoteRobot.welcomeFrame {
6562
findText(createdProjectName).click()
6663
}
6764
val ideaFrame = getIdeaFrameForBuildSystem(remoteRobot, ideaBuildSystem)
68-
with (ideaFrame) {
65+
return with (ideaFrame) {
6966
val newClassName = "Arithmetic"
70-
createNewJavaClass(newClassName, "org.example")
67+
createNewJavaClass(newClassName, "Main")
7168
textEditor().typeAdditionFunction(newClassName)
7269
openUTBotDialogFromProjectViewForClass(newClassName)
7370
assertThat(unitTestBotDialog.generateTestsButton.isEnabled().not())

0 commit comments

Comments
 (0)