app.cash.paparazzi.gradle.reporting.AllTestResults.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of paparazzi-gradle-plugin Show documentation
Show all versions of paparazzi-gradle-plugin Show documentation
A Gradle plugin to set up the Paparazzi test library
The newest version!
package app.cash.paparazzi.gradle.reporting
import java.util.TreeMap
/**
* The model for the test report.
*/
internal class AllTestResults : CompositeTestResults(null) {
private val packages: MutableMap = TreeMap()
override val title: String
get() = "Test Summary"
override val baseUrl: String
get() = "index.html"
fun getPackages(): Collection = packages.values
fun addTest(
classId: Long,
className: String,
classDisplayName: String = className,
testName: String,
testDisplayName: String = testName,
duration: Long
): TestResult {
val packageResults = addPackageForClass(className)
return addTest(
packageResults.addTest(
classId, className, classDisplayName, testName, testDisplayName, duration
)
)
}
fun addTestClass(
classId: Long,
className: String,
classDisplayName: String = className
): ClassTestResults {
return addPackageForClass(className).addClass(classId, className, classDisplayName)
}
private fun addPackageForClass(className: String): PackageTestResults {
var packageName = className.substringBeforeLast(".")
if (packageName == className) {
packageName = ""
}
return addPackage(packageName)
}
private fun addPackage(packageName: String): PackageTestResults {
var packageResults = packages[packageName]
if (packageResults == null) {
packageResults = PackageTestResults(packageName, this)
packages[packageName] = packageResults
}
return packageResults
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy