-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for WebAssets class (#412)
* Add unit test for WebAssets class * Make asset files map available for reuse * Make assetPathsMap an internal variable * Reuse asset paths mapping from sut in the test class * Use private instead of internal --------- Co-authored-by: Takahiro Menju <[email protected]>
- Loading branch information
Showing
3 changed files
with
52 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...uild/roborazzi-gradle-plugin/src/test/java/io/github/takahirom/roborazzi/WebAssetsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.takahirom.roborazzi | ||
|
||
import junit.framework.TestCase.assertTrue | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.rules.TemporaryFolder | ||
import java.io.File | ||
import kotlin.test.Test | ||
|
||
class WebAssetsTest { | ||
|
||
@get:Rule | ||
val tmpDir: TemporaryFolder = TemporaryFolder.builder().assureDeletion().build() | ||
|
||
private lateinit var sut: WebAssets | ||
|
||
@Before | ||
fun setUp() { | ||
sut = WebAssets.create() | ||
} | ||
|
||
@Test | ||
fun testWritesWebAssetsSuccessfullyToReportsDirectory() { | ||
val reportDir = tmpDir.newFolder("roborazzi-reports") | ||
val assetFiles = sut.assets.map { File(reportDir, "assets/$it") } | ||
|
||
sut.writeToRoborazziReportsDir(reportDir) | ||
|
||
assetFiles.forEach { file-> | ||
assertTrue(file.exists()) | ||
} | ||
} | ||
} |