ฉันมีการทดสอบหน่วยอย่างง่าย ๆ เพื่อให้แน่ใจว่าหน้าต่างหลักของแอปพลิเคชันไม่ได้รับการตกแต่ง:
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) การทดสอบดำเนินไปด้วยดี ฉันจะทำแบบทดสอบเดียวกันจากแตงกวาได้อย่างไร
public final class WindowAspectSteps {
@Then("the main window should be undecorated")
public void checkMainWindowIsUndecorated() {
//????
}
}
ฉันพยายามทำให้ WindowAspectSteps ขยาย AbstractMainWindowTest แต่ตัวแปรหน้าต่างยังคงเป็นโมฆะ