|
| 1 | +package org.jesperancinha.plugins.omni.reporter.domain.reports |
| 2 | + |
| 3 | +import io.kotest.matchers.nulls.shouldNotBeNull |
| 4 | +import io.kotest.matchers.string.shouldEndWith |
| 5 | +import io.kotest.matchers.string.shouldHaveMinLength |
| 6 | +import io.kotest.matchers.string.shouldNotBeEmpty |
| 7 | +import io.kotest.matchers.string.shouldStartWith |
| 8 | +import io.kotest.matchers.types.shouldBeInstanceOf |
| 9 | +import org.jesperancinha.plugins.omni.reporter.processors.ReportType |
| 10 | +import org.jesperancinha.plugins.omni.reporter.utils.toFile |
| 11 | +import org.junit.jupiter.api.Test |
| 12 | + |
| 13 | +internal class OmniJacocoFileAdapterTest { |
| 14 | + |
| 15 | + @Test |
| 16 | + fun `should generate itg jacoco report`() { |
| 17 | + |
| 18 | + val jacocoItg = javaClass.getResource("/jacoco.formats/jacoco-itg.xml") |
| 19 | + jacocoItg.shouldNotBeNull() |
| 20 | + val rootJacocoItg = javaClass.getResource("/jacoco.formats") |
| 21 | + rootJacocoItg.shouldNotBeNull() |
| 22 | + |
| 23 | + val reportFileAdapter = ReportType.createReportFileAdapter( |
| 24 | + jacocoItg.toFile(), |
| 25 | + false, |
| 26 | + rootJacocoItg.toFile(), |
| 27 | + rootJacocoItg.toFile() |
| 28 | + ) |
| 29 | + |
| 30 | + reportFileAdapter.shouldBeInstanceOf<OmniJacocoFileAdapter>() |
| 31 | + |
| 32 | + val generatePayload = reportFileAdapter.generatePayload(false, listOf(rootJacocoItg.toFile())) |
| 33 | + |
| 34 | + generatePayload.shouldNotBeEmpty() |
| 35 | + generatePayload.shouldHaveMinLength(10) |
| 36 | + generatePayload.shouldStartWith("<") |
| 37 | + generatePayload.shouldEndWith(">") |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + fun `should generate pbr jacoco report`() { |
| 42 | + |
| 43 | + val jacocoItg = javaClass.getResource("/jacoco.formats/jacoco-pbr.xml") |
| 44 | + jacocoItg.shouldNotBeNull() |
| 45 | + val rootJacocoItg = javaClass.getResource("/jacoco.formats") |
| 46 | + rootJacocoItg.shouldNotBeNull() |
| 47 | + |
| 48 | + val reportFileAdapter = ReportType.createReportFileAdapter( |
| 49 | + jacocoItg.toFile(), |
| 50 | + false, |
| 51 | + rootJacocoItg.toFile(), |
| 52 | + rootJacocoItg.toFile() |
| 53 | + ) |
| 54 | + |
| 55 | + reportFileAdapter.shouldBeInstanceOf<OmniJacocoFileAdapter>() |
| 56 | + |
| 57 | + val generatePayload = reportFileAdapter.generatePayload(false, listOf(rootJacocoItg.toFile())) |
| 58 | + |
| 59 | + generatePayload.shouldNotBeEmpty() |
| 60 | + generatePayload.shouldHaveMinLength(10) |
| 61 | + generatePayload.shouldStartWith("<") |
| 62 | + generatePayload.shouldEndWith(">") |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + fun `should generate pjs jacoco report`() { |
| 67 | + |
| 68 | + val jacocoItg = javaClass.getResource("/jacoco.formats/jacoco-pjs.xml") |
| 69 | + jacocoItg.shouldNotBeNull() |
| 70 | + val rootJacocoItg = javaClass.getResource("/jacoco.formats") |
| 71 | + rootJacocoItg.shouldNotBeNull() |
| 72 | + |
| 73 | + val reportFileAdapter = ReportType.createReportFileAdapter( |
| 74 | + jacocoItg.toFile(), |
| 75 | + false, |
| 76 | + rootJacocoItg.toFile(), |
| 77 | + rootJacocoItg.toFile() |
| 78 | + ) |
| 79 | + |
| 80 | + reportFileAdapter.shouldBeInstanceOf<OmniJacocoFileAdapter>() |
| 81 | + |
| 82 | + val generatePayload = reportFileAdapter.generatePayload(false, listOf(rootJacocoItg.toFile())) |
| 83 | + |
| 84 | + generatePayload.shouldNotBeEmpty() |
| 85 | + generatePayload.shouldHaveMinLength(10) |
| 86 | + generatePayload.shouldStartWith("<") |
| 87 | + generatePayload.shouldEndWith(">") |
| 88 | + } |
| 89 | +} |
0 commit comments