artem_zin
10/09/2017, 5:59 PMrobfletcher
10/09/2017, 5:59 PMsnowe
10/09/2017, 6:00 PMartem_zin
10/09/2017, 6:01 PMUsersApiSpec : Spek({
val env by memoized { Environment() }
it("does not access db by default") {
verifyZeroInvocations(env.dep1)
}
})
class Environment {
dep1 = mock<Dep1>()
dep2 = mock<Dep2>()
}
snowe
10/09/2017, 6:01 PMartem_zin
10/09/2017, 6:01 PM@RunWith(SpringRunner.class); @SpringBootTest
snowe
10/09/2017, 6:01 PMsnowe
10/09/2017, 6:01 PMSpringRunner
uses JunitRunner
btwartem_zin
10/09/2017, 6:01 PMartem_zin
10/09/2017, 6:03 PM@RunWith(SpringRunner.class); @SpringBootTest
if they opened API of classes used by the implementation of SpringRunner
you should be able to programmatically replicated that for Spekartem_zin
10/09/2017, 6:04 PMartem_zin
10/09/2017, 6:10 PMsnowe
10/09/2017, 6:26 PMartem_zin
10/09/2017, 7:37 PMsnowe
10/09/2017, 7:48 PMinit {
// Configure Spring DI, it's 100% possible
SpringDi.inject(this)
}
val env by memoized { Environment() }
With plain junit if I want to pull it into another class I can, I still use autowired, I just extend or implement that class.artem_zin
10/09/2017, 7:51 PM@Test
cases 🙂snowe
10/09/2017, 7:51 PMartem_zin
10/09/2017, 7:53 PMartem_zin
10/09/2017, 7:54 PMEnvironment
very useful, it clearly separates tests from env setup/deps resolutionsnowe
10/09/2017, 9:31 PMraniejade
10/10/2017, 2:53 AM@ContextConfiguration(classes = arrayOf(MyConfiguration::class))
object MySpec: Spek({
val context = createContext(MySpec::class)
val foo: Foo by context.inject()
it("blah blah blah") {
foo.doSomething()
}
})
snowe
10/10/2017, 3:57 PMharshitbangar
10/11/2017, 10:09 AMbdawg.io
10/11/2017, 10:22 PMbuild.gradle.kts
instructing intellij to execute the gradle test
task in debug modeartem_zin
10/11/2017, 11:05 PMartem_zin
10/11/2017, 11:08 PM--debug-jvm
see <https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_test>
bdawg.io
10/11/2017, 11:09 PMharshitbangar
10/12/2017, 12:48 PMharshitbangar
10/12/2017, 1:02 PM