我有一个简单的单元测试来确保应用程序的主窗口是未修饰的:
public class MainWindowUT extends AbstractMainWindowTest {
@Test
public void whenApplicationIsStarted_thenMainFrameIsUndecorated() {
@SuppressWarnings("boxing")
Boolean isUndecorated = GuiActionRunner.execute(() -> window.target().isUndecorated());
assertThat(isUndecorated).isTrue();
}
}
AbstractMainWindowTest 是:
public abstract class AbstractMainWindowTest extends AssertJSwingJUnitTestCase {
protected FrameFixture window;
@Override
protected void onSetUp() {
ScaleRuler frame = GuiActionRunner.execute(() -> new ScaleRuler());
window = new FrameFixture(robot(), frame);
window.show();
}
}
ScaleRuler 是我的框架,目前什么都不做,只是 setUndecorated(true)。测试运行良好。如何从 Cucumber 执行相同的测试?
public final class WindowAspectSteps {
@Then("the main window should be undecorated")
public void checkMainWindowIsUndecorated() {
//????
}
}
我试图让 WindowAspectSteps 扩展 AbstractMainWindowTest,但窗口变量仍然为空。
慕桂英546537
相关分类