Skip to content

Commit

Permalink
Merge pull request #5204 from XiangRongLin/fix_before_all
Browse files Browse the repository at this point in the history
Use @BeforeClass for ContentSettingsManagerTest.beforeClass
  • Loading branch information
Stypox authored Dec 19, 2020
2 parents f590993 + e0ee3dc commit 2880280
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.SharedPreferences
import org.junit.Assert
import org.junit.Assume
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Suite
Expand All @@ -22,24 +23,27 @@ class ContentSettingsManagerTest {
@RunWith(MockitoJUnitRunner::class)
class ExportTest {

private lateinit var preferences: SharedPreferences
private lateinit var newpipeDb: File
private lateinit var newpipeSettings: File

@Before
fun beforeClass() {
companion object {
private lateinit var newpipeDb: File
private lateinit var newpipeSettings: File

val dbPath = javaClass.classLoader?.getResource("settings/newpipe.db")?.file
val settingsPath = javaClass.classLoader?.getResource("settings/newpipe.settings")?.path
Assume.assumeNotNull(dbPath)
Assume.assumeNotNull(settingsPath)
@JvmStatic
@BeforeClass
fun setupFiles() {
val dbPath = ExportTest::class.java.classLoader?.getResource("settings/newpipe.db")?.file
val settingsPath = ExportTest::class.java.classLoader?.getResource("settings/newpipe.settings")?.path
Assume.assumeNotNull(dbPath)
Assume.assumeNotNull(settingsPath)

newpipeDb = File(dbPath!!)
newpipeSettings = File(settingsPath!!)
newpipeDb = File(dbPath!!)
newpipeSettings = File(settingsPath!!)
}
}

private lateinit var preferences: SharedPreferences

@Before
fun before() {
fun setupMocks() {
preferences = Mockito.mock(SharedPreferences::class.java, Mockito.withSettings().stubOnly())
}

Expand Down

0 comments on commit 2880280

Please sign in to comment.