Skip to content

Commit

Permalink
Add functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo authored and Goooler committed Aug 26, 2024
1 parent 2721206 commit 2426aee
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/groovy/me/champeau/gradle/BaseFunctionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ abstract class BaseFunctionalTest extends Specification {
}
}

void hasmarkdownReport(String lookup = '') {
hasReport('japi', 'md', lookup)
}

void hasTextReport(String lookup = '') {
hasReport('japi', 'txt', lookup)
}
Expand All @@ -68,6 +72,10 @@ abstract class BaseFunctionalTest extends Specification {
hasReport('rich', 'html', lookup)
}

void noMarkdownReport() {
assert !getReport('japi', 'md').exists()
}

void noTxtReport() {
assert !getReport('japi', 'txt').exists()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class BomFunctionalTest extends BaseFunctionalTest {
hasTextReport('CLASS FILE FORMAT VERSION: 50.0 <- 50.0')
noSemverReport()
noHtmlReport()
noMarkdownReport()
noRichReport()

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ClasspathIsUsedFunctionalTest extends BaseFunctionalTest {
\t=== UNCHANGED CONSTRUCTOR: PUBLIC Subtype()
""")
noSemverReport()
noMarkdownReport()
noHtmlReport()
noRichReport()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Compare2JarsFunctionalTest extends BaseFunctionalTest {
hasTextReport('Comparing source compatibility of commons-lang3-3.6.jar against commons-lang3-3.5.jar')
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noSemverReport()
noMarkdownReport()
noHtmlReport()
noRichReport()

Expand All @@ -33,6 +34,7 @@ class Compare2JarsFunctionalTest extends BaseFunctionalTest {
hasTextReport('Comparing source compatibility of commons-lang3-3.6.jar against commons-lang3-3.5.jar')
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noSemverReport()
noMarkdownReport()
noHtmlReport()
noRichReport()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Compare2LibrariesFunctionalTest extends BaseFunctionalTest {
hasTextReport('Comparing source compatibility of commons-lang3-3.6.jar against commons-lang3-3.5.jar')
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noSemverReport()
noMarkdownReport()
noHtmlReport()
noRichReport()

Expand Down
43 changes: 43 additions & 0 deletions src/test/groovy/me/champeau/gradle/ReportsFunctionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
\t\t\t</td>""")
hasHtmlReport('<a href="#org.apache.commons.lang3.event.EventListenerSupport">')
noTxtReport()
noMarkdownReport()
noSemverReport()
noRichReport()

Expand All @@ -42,6 +43,7 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
hasRichReport('<a class=\'navbar-brand\' href=\'#\'>Binary compatibility report</a>')
hasRichReport('A test of rich report')
noTxtReport()
noMarkdownReport()
noSemverReport()
noHtmlReport()

Expand All @@ -60,6 +62,7 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
result.task(":japicmpSemver").outcome == TaskOutcome.SUCCESS
hasSemverReport('0.1.0')
noTxtReport()
noMarkdownReport()
noHtmlReport()
noRichReport()

Expand All @@ -69,4 +72,44 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
then:
result.task(":japicmpSemver").outcome == TaskOutcome.UP_TO_DATE
}

def "can generate a markdown report"() {
when:
def result = run 'japicmpMarkdown'

then:
result.task(":japicmpMarkdown").outcome == TaskOutcome.SUCCESS
hasmarkdownReport('# Compatibility Report')
hasmarkdownReport('- **Report only summary**: No')
noTxtReport()
noSemverReport()
noHtmlReport()
noRichReport()

when:
result = run 'japicmpMarkdown'

then:
result.task(":japicmpMarkdown").outcome == TaskOutcome.UP_TO_DATE
}

def "can generate a summary-only markdown report"() {
when:
def result = run 'japicmpMarkdownReportOnlySummary'

then:
result.task(":japicmpMarkdownReportOnlySummary").outcome == TaskOutcome.SUCCESS
hasmarkdownReport('# Compatibility Report')
hasmarkdownReport('- **Report only summary**: Yes')
noTxtReport()
noSemverReport()
noHtmlReport()
noRichReport()

when:
result = run 'japicmpMarkdownReportOnlySummary'

then:
result.task(":japicmpMarkdownReportOnlySummary").outcome == TaskOutcome.UP_TO_DATE
}
}
13 changes: 13 additions & 0 deletions src/test/test-projects/html-report/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ task japicmpRich(type: me.champeau.gradle.japicmp.JapicmpTask) {
}
}

task japicmpMarkdown(type: me.champeau.gradle.japicmp.JapicmpTask) {
oldClasspath.from(configurations.baseline)
newClasspath.from(configurations.current)
mdOutputFile = layout.buildDirectory.file('reports/japi.md').get().asFile
}

task japicmpMarkdownReportOnlySummary(type: me.champeau.gradle.japicmp.JapicmpTask) {
oldClasspath.from(configurations.baseline)
newClasspath.from(configurations.current)
mdOutputFile = layout.buildDirectory.file('reports/japi.md').get().asFile
reportOnlySummary = true
}

task japicmpSemver(type: me.champeau.gradle.japicmp.JapicmpTask) {
oldClasspath.from(configurations.baseline)
newClasspath.from(configurations.current)
Expand Down

0 comments on commit 2426aee

Please sign in to comment.