thomasnield
10/05/2018, 6:08 AMRoman
10/05/2018, 6:25 AMRoman
10/05/2018, 6:25 AMclass HomeController : Controller() {
private val api: Rest by inject()
SiebelsTim
10/05/2018, 6:46 AMRoman
10/05/2018, 7:12 AMclass HomeControllerTest {
companion object {
lateinit var homeController: HomeController
@BeforeAll
@JvmStatic
fun main() {
val latch = CountDownLatch(1)
SwingUtilities.invokeLater {
JFXPanel()
latch.countDown()
}
if (!latch.await(5L, TimeUnit.SECONDS)) {
throw ExceptionInInitializerError()
}
homeController = HomeController()
}
}
@Test
fun `loadErpPrinters with exception`() {
val mock = mock<Rest>() {
on { loadErpPrinters() } doThrow KPrinterApiException()
}
}
SiebelsTim
10/05/2018, 8:04 AMRoman
10/05/2018, 9:21 AMSiebelsTim
10/05/2018, 10:05 AMmockk()
as I've demonstrated in the snippet. I've just shown two different methods of creating an object that will be injected for tests. You don't need the TestRestService
when you use mockk()
. It's zero more classes.Roman
10/05/2018, 10:11 AMamanda.hinchman-dominguez
10/05/2018, 10:26 AMnimakro
10/05/2018, 11:51 AMSiebelsTim
10/05/2018, 12:31 PMmikehearn
10/05/2018, 12:39 PMNico Smeenk
10/05/2018, 3:29 PMHullaballoonatic
10/05/2018, 3:32 PMHullaballoonatic
10/05/2018, 3:33 PMRuckus
10/05/2018, 3:33 PMhudsonb
10/05/2018, 3:33 PMHullaballoonatic
10/05/2018, 3:34 PMRuckus
10/05/2018, 3:35 PMlabel
builder can take that as a parameter and bind to it directly
label(controller.statusProperty)
Then any time you update the status property, the label will update to match it.Hullaballoonatic
10/05/2018, 3:36 PMRuckus
10/05/2018, 3:38 PMHamza
10/05/2018, 3:41 PMNico Smeenk
10/05/2018, 3:42 PMclass Application : App(TestView::class)
class TestView : View() {
private val testProperty = SimpleStringProperty()
override val root = vbox {
textfield (testProperty)
text (testProperty)
}
init {
testProperty.set("abc")
}
}
nimakro
10/05/2018, 5:09 PMamanda.hinchman-dominguez
10/05/2018, 5:24 PMSiebelsTim
10/05/2018, 6:13 PMamanda.hinchman-dominguez
10/05/2018, 6:20 PMSiebelsTim
10/05/2018, 6:48 PMthomasnield
10/05/2018, 7:38 PM