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

為了賬號安全,請及時綁定郵箱和手機立即綁定

多條自動化用例,執行順序問題

我想問下老師,最后一節課實戰,用例編寫順序是加減乘除,為什么運行自動化的執行順序是加除乘減

正在回答

1 回答

用例執行默認非順序的,注意這里使用的是JUnit4,參照JUnit4用例執行順序方法設置就可以實現想要的順序

JUnit是通過@FixMethodOrder注解(annotation)來控制測試方法的執行順序的。

@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.JVM)
public?class?DemoTest?

相關順序控制如下:
  • MethodSorters.JVM

Leaves the test methods in the order returned by the JVM. Note that the order from the JVM may vary from run to run (按照JVM得到的方法順序,也就是代碼中定義的方法順序)

  • MethodSorters.DEFAULT(默認的順序)

Sorts the test methods in a deterministic, but not predictable, order() (以確定但不可預期的順序執行)

  • MethodSorters.NAME_ASCENDING

Sorts the test methods by the method name, in lexicographic order, with Method.toString() used as a tiebreaker (按方法名字母順序執行)


1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

多條自動化用例,執行順序問題

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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