----- Original Message -----
From: "Vojtech Szocs" <vszocs(a)redhat.com>
To: devel(a)ovirt.org
Sent: Monday, August 4, 2014 5:01:10 PM
Subject: [ovirt-devel] JUnit rule for testing UiCommon code
Hi,
I wrote a small patch to aid UI developers in testing UiCommon code:
http://gerrit.ovirt.org/#/c/31021/
It's merged now in master.
This patch adds a JUnit rule used to set up the necessary UiCommon
infrastructure (represented by mock objects) as expected by existing
code (hidden expectations represented by static calls).
You can also access these (infrastructure) mock objects to stub their
behavior, if necessary.
Example - UiCommon infrastructure setup per test class:
public class MyTest {
@ClassRule
public static UiCommonSetup setup = new UiCommonSetup();
// This is optional, but often necessary
@BeforeClass
public static void stubUiCommonInfra() {
AsyncDataProvider adp = setup.getMocks().asyncDataProvider();
when(adp.isWindowsOsType(anyInt())).thenReturn(true);
}
// Actual test code to exercise model instance(s)
}
Example - UiCommon infrastructure setup per test method:
public class MyTest {
@Rule
public UiCommonSetup setup = new UiCommonSetup();
// This is optional, but often necessary
@Before
public void stubUiCommonInfra() {
AsyncDataProvider adp = setup.getMocks().asyncDataProvider();
when(adp.isWindowsOsType(anyInt())).thenReturn(true);
}
// Actual test code to exercise model instance(s)
}
When creating specific model instances (test subjects), stubbing
methods to avoid hidden static calls shouldn't be necessary anymore.
Regards,
Vojtech
_______________________________________________
Devel mailing list
Devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/devel