Skip to content

Commit

Permalink
jacoco UI tests coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
nizienko committed Mar 4, 2024
1 parent 126faaf commit d2a2ce6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/runUiTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ jobs:
- name: Move video
if: ${{ failure() }}
run: mv video build/reports

- name: Save fails report
if: ${{ failure() }}
- name: Wait for reports
uses: jakejarvis/wait-action@master
with:
time: '10s'
- name: Save reports
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.reportName }}
Expand Down
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.8.21"
id("org.jetbrains.intellij") version "1.13.3"
jacoco
}

group = "com.github.nizienko"
Expand Down Expand Up @@ -63,6 +64,21 @@ tasks.downloadRobotServerPlugin {
version.set(robotVersion)
}

jacoco {
toolVersion = "0.8.10"
applyTo(tasks.runIdeForUiTests.get())
}

val uiTestsCoverageReport = tasks.register<JacocoReport>("uiTestsCoverageReport") {
executionData(tasks.runIdeForUiTests.get())
sourceSets(sourceSets.main.get())

reports {
xml.required.set(true)
html.required.set(true)
}
}

tasks.runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
Expand All @@ -73,11 +89,24 @@ tasks.runIdeForUiTests {
systemProperty("apple.laf.useScreenMenuBar", "false")
systemProperty("idea.trust.all.projects", "true")
systemProperty("ide.show.tips.on.startup.default.value", "false")

configure<JacocoTaskExtension> {

// 221+ uses a custom classloader and jacoco fails to find classes
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
finalizedBy(uiTestsCoverageReport)
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}

// we need the coverage from Idea process, not from test task
configure<JacocoTaskExtension> {
isEnabled = false
}
}
25 changes: 18 additions & 7 deletions src/test/kotlin/CreateSwitchPropertiesTest.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
import com.intellij.remoterobot.RemoteRobot
import com.intellij.remoterobot.fixtures.CommonContainerFixture
import com.intellij.remoterobot.fixtures.ComponentFixture
import com.intellij.remoterobot.fixtures.ContainerFixture
import com.intellij.remoterobot.fixtures.component
import com.intellij.remoterobot.fixtures.*
import com.intellij.remoterobot.search.locators.byXpath
import com.intellij.remoterobot.steps.CommonSteps
import com.intellij.remoterobot.stepsProcessing.step
import com.intellij.remoterobot.utils.keyboard
import com.intellij.remoterobot.utils.waitFor
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test
import java.time.Duration

class CreateSwitchPropertiesTest {
private val robot = RemoteRobot("http://127.0.0.1:8082")
private val steps = CommonSteps(robot)
companion object {
private val robot = RemoteRobot("http://127.0.0.1:8082")
private val steps = CommonSteps(robot)

@JvmStatic
@AfterAll
fun afterAll(): Unit {
steps.invokeAction("Exit")
robot.idea {
find<ContainerFixture>(byXpath("//div[@class='MyDialog']"))
.find<JButtonFixture>(byXpath("//div[@text='Exit']"))
.click()
}
}
}

@Test
fun createPropSwitchFileTest() {
step("Create project") {
robot.welcomeFrame {
component(byXpath("//div[(@accessiblename='New Project' and @class='MainButton') or @defaulticon='createNewProjectTab.svg']"))
.click()
component(byXpath("//div[@class='ProjectTypeListWithSearch']"))
component(byXpath("//div[@class='ProjectTypeListWithSearch']"), Duration.ofSeconds(15))
.findText("New Project")
.click()
component(byXpath("//div[contains(@action, 'Kotlin') and @class='SegmentedButton']"))
Expand Down

0 comments on commit d2a2ce6

Please sign in to comment.