亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Cucumber 的 AssertJ Swing 測試

使用 Cucumber 的 AssertJ Swing 測試

躍然一笑 2022-12-28 11:02:28
我有一個簡單的單元測試來確保應用程序的主窗口是未修飾的: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,但窗口變量仍然為空。
查看完整描述

1 回答

?
慕桂英546537

TA貢獻1848條經驗 獲得超10個贊

@BeforeJUnit ( )的注釋@org.junit.Before不適用于 Cucumber。
Cucumber 有自己的 @Before 注解@cucumber.api.java.Before) :

事實上,JUnit 和 Cucumber 實際上是兩個不同的測試運行器平臺,因此擁有自己的測試運行器和相關設施(而有些在邏輯方面是通用的)。

作為解決方法,嘗試@Before在測試抽象類的設置方法上添加 2 個不同的注釋(junit 和 cucumber 的)或創建兩個不同的方法:一個與@cucumber.api.java.Before另一個@org.junit.Before都委托給執行設置處理的通用方法。


查看完整回答
反對 回復 2022-12-28
  • 1 回答
  • 0 關注
  • 100 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號