-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello!
I have a question over the junit test.
We could test this line BindUtils.postNotifyChange(null, null, this, ACTIVE_STEP); with junit.
I use Junit5 and I'm doing a test for my stepbar component and i have to test the next step but i don't know how to do it because I have that to notify the change :(
I'm using this action BindUtils.postNotifyChange(...); to notify the change to the component.
Do you have any tips to mock this action (BindUtils.postNotifyChange) ?
I have an error in the console like this when I run the test:
java.lang.IllegalStateException: Not in an execution at org.zkoss.zk.ui.event.impl.EventQueueProviderImpl.lookup(EventQueueProviderImpl.java:67) at org.zkoss.zk.ui.event.EventQueues.lookup(EventQueues.java:130) at org.zkoss.bind.BindUtils.postNotifyChange(BindUtils.java:69) at ch.unil.escan.viewModel.StepBarModel.navigateTo(StepBarModel.java:42) at ch.unil.escan.viewModel.StepBarModel.nextToNotify(StepBarModel.java:34) at ch.unil.escan.viewModel.ScanViewModel.validOption(ScanViewModel.java:273) at ch.unil.escan.viewModel.ScanViewModelTest.testValidOption(ScanViewModelTest.java:78) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
Thank you.
Yvan
if you test with JUnit, there is no ZK Execution
object existing in the context, it's a class that wraps a HttpServletRequest
. Since there is no browser request, that's why you see java.lang.IllegalStateException: Not in an execution
ZATS already mimics the whole environment for you and provides API to assert a component's state, please try to run junit with it. If you still have problems, please attach the related code.
Asked: 2023-04-03 19:54:00 +0800
Seen: 5 times
Last updated: Apr 24