我试图弄清楚如何让我的 JUnits 测试按特定顺序运行,以及如果其中一个测试失败,则停止所有测试。下面我只包含了一些简单的操作栏项目测试。我基本上要确保的是,当我通过命令行运行构建/测试时,如果其中一个测试失败,我希望测试停止。有什么建议吗?
public void testPreconditions() {
assertNotNull(instrumentation);
assertNotNull(mWeb);
assertNotNull(mActivity);
}
protected void setUp() throws Exception {
super.setUp();
instrumentation = getInstrumentation();
mActivity = getActivity();
setActivityInitialTouchMode(false);
mWeb = (WebView) mActivity
.findViewById(com.jaisonbrooks.webview.R.id.webview_main);
mMockWebViewClient = new MockWebViewClient();
mWeb.setWebViewClient(mMockWebViewClient);
mSettings = mWeb.getSettings();
}
public void testThatButtonReloadWorks() {
final View view = mActivity
.findViewById(com.jaisonbrooks.webview.R.id.menu_refresh);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
view.requestFocus();
view.callOnClick();
}
});
}
public void testThatButtonForwardWorks() {
final View view = mActivity
.findViewById(com.jaisonbrooks.webview.R.id.menu_forward);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
view.requestFocus();
view.callOnClick();
}
});
}
public void testThatButtonBackWorks() {
final View view = mActivity
.findViewById(com.jaisonbrooks.webview.R.id.menu_back);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
view.requestFocus();
view.callOnClick();
}
});
}