Skip to content

Commit

Permalink
A bit more corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
alisevych committed Aug 23, 2023
1 parent d464a34 commit fd5429d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
}
Expand All @@ -32,7 +32,7 @@ fun TextEditorFixture.typeDivisionFunction(className: String) : String {
key(KeyEvent.VK_END)
enterText("{")
enter()
enterText("// ${TEST_RUN_NUMBER}")
enterText("// Test run ${TEST_RUN_NUMBER}")
enter()
enterText("return a / b;")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ 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() {

@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()
Expand All @@ -36,36 +35,34 @@ class UnitTestBotActionTest : BaseTest() {
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
}
}

@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, "Main")
textEditor().typeAdditionFunction(newClassName)
Expand Down

0 comments on commit fd5429d

Please sign in to comment.