edvin / tornadofx-guide

TornadoFX Guide
133 stars 67 forks source link

A Testing story would be useful #48

Open kastork opened 6 years ago

kastork commented 6 years ago

I realized today there's really not a story about testing in the context of TornadoFx contained in the guide.

For example, I wanted to start an app by building kotlin-test specs to call and integrate domain objects against a public Restful API using the TornadoFx Rest capability. But then I discover that Rest is a TornadoFx controller and there's no obvious way to instantiate one for the purposes of testing (by inject isn't really something you can do in a test class (or is it?)).

I'm sure there are many other situations where a discussion of how to do testing would be beneficial to many users.

edvin commented 6 years ago

This would be very helpful. You can get a Component instance by calling FX.find<ComponentType>() at any time, it has the same effect as injection. In a pinch you can even instantiate it manually and call init(), but that's not going to work if you're utilizing scopes.