gpt4 book ai didi

android - CircleCI ./gradlew 测试命令失败

转载 作者:行者123 更新时间:2023-11-29 23:20:00 25 4
gpt4 key购买 nike

gradlew 测试命令在 CircleCI 上失败。当我在本地执行相同的命令时,它工作正常并且所有测试用例都通过了。我附上了 yml 文件,来自 CircleCI 的日志和我的测试类。

这是我的 yml 文件。

version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-28
environment:
JVM_OPTS: -Xmx4096m
CC_TEST_REPORTER_ID: XXXXXXXXXXXXXXXXXX
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
# - run:
# name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
# command: sudo chmod +x ./gradlew
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
# - run:
# name: Run Lint Tests
# command: ./gradlew lint test
- run:
name: Run Tests
command: ./gradlew test --info

# - run:
# name: Run Instrument Tests
# command: ./gradlew connectedAndroidTest

- store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: app/build/reports
destination: reports
- store_test_results: # for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: app/build/test-results

当我检查 CircleCI 的日志时,这些是日志:

Executing transform IdentityTransform -> IdentityTransform on artifact core.jar (com.google.zxing:core:3.3.0) Executing transform IdentityTransform -> IdentityTransform on artifact protobuf-java.jar (com.google.protobuf:protobuf-java:2.6.1) Executing transform IdentityTransform -> IdentityTransform on artifact backport-util-concurrent.jar (backport-util-concurrent:backport-util-concurrent:3.1) Executing transform IdentityTransform -> IdentityTransform on artifact xercesMinimal.jar (nekohtml:xercesMinimal:1.9.6.2) Executing transform IdentityTransform -> IdentityTransform on artifact nekohtml.jar (nekohtml:nekohtml:1.9.6.2) Executing transform MockableJarTransform on file /opt/android/sdk/platforms/android-28/android.jar Starting process 'Gradle Test Executor 2'. Working directory: /home/circleci/code/app Command: /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dorg.gradle.native=false -noverify -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea -cp /home/circleci/.gradle/caches/4.10.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 2' Successfully started process 'Gradle Test Executor 2'

com.mindvalley.mva.loginmodule.LoginActivityTest > isSkipLoginVisible STANDARD_OUT [Robolectric] com.mindvalley.mva.loginmodule.LoginActivityTest.isSkipLoginVisible: sdk=28; resources=binary Called loadFromPath(/system/framework/framework-res.apk, true); mode=binary sdk=28

com.mindvalley.mva.loginmodule.LoginActivityTest > isSkipLoginVisible SKIPPED

Task :app:testInternalReleaseUnitTest FAILED :app:testInternalReleaseUnitTest (Thread[Task worker for ':' Thread 2,5,main]) completed. Took 3.413 secs.

失败:构建失败,出现异常。

  • 出了什么问题:任务“:app:testInternalReleaseUnitTest”执行失败。

    Process 'Gradle Test Executor 2' finished with non-zero exit value 137 This problem might be caused by incorrect test process configuration. Please refer to the test execution section in the user guide at https://docs.gradle.org/4.10.1/userguide/java_plugin.html#sec:test_execution

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获取 完整的见解。

  • https://help.gradle.org 获得更多帮助

我的登录测试 Activity

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, application = MockApplication.class)
public class LoginActivityTest {

private LoginActivity activity;

@Before
public void setup() {
activity = Robolectric.buildActivity(LoginActivity.class).create().resume().get();
}

@Test
public void shouldNotBeNull() {
Assert.assertNotNull(activity);
}

/**
* check by default visibility. It should be not visible
* Once we change variable in Login module it should be Visible
*/
@Test
public void isSkipLoginVisible() {
TextView skipLogin = activity.findViewById(com.mindvalley.loginmodule.R.id.skip_login);
LoginModule.getInstance().setSkipLogin(false);
activity.setSkipLoginVisibility();
Assert.assertTrue(skipLogin.getVisibility() == View.GONE);
LoginModule.getInstance().setSkipLogin(true);
activity.setSkipLoginVisibility();
Assert.assertTrue( skipLogin.getVisibility() == View.VISIBLE);
}

@Test
public void enableActionButtonTest() {
CustomFeedbackText loginButton = activity.findViewById(com.mindvalley.loginmodule.R.id.login_btn_login);
String email = "";
String password = "";
activity.enableActionButton(email, password);
Assert.assertTrue(!loginButton.isEnabled());
email = "harsh@mindvalley.com";
password = "123";
activity.enableActionButton(email, password);
Assert.assertTrue(loginButton.isEnabled());
}

@Test
public void skipLoginClicked() {
TextView skipLogin = activity.findViewById(com.mindvalley.loginmodule.R.id.skip_login);
Assert.assertTrue(!PreferenceManager.getBoolean(LoginModule.SKIP_LOGIN, false));
skipLogin.performClick();
Assert.assertTrue(PreferenceManager.getBoolean(LoginModule.SKIP_LOGIN, false));
}

@Test
public void sanitizeLogin() {
String email = "";
String password = "";
Assert.assertTrue(!activity.sanitizeLogin(email, password));
email = "harsh";
password = "";
Assert.assertTrue(!activity.sanitizeLogin(email, password));
email = "harsh@mindvalley";
password = "";
Assert.assertTrue(!activity.sanitizeLogin(email, password));
email = "harsh@mindvalley.com";
password = "";
Assert.assertTrue(!activity.sanitizeLogin(email, password));
email = "harsh@mindvalley.com";
password = "test";
Assert.assertTrue(!activity.sanitizeLogin(email, password));
email = "harsh@mindvalley.com";
password = "test123";
Assert.assertTrue(activity.sanitizeLogin(email, password));
}

@Test
public void loginClicked() {
CustomFeedbackText loginButton = activity.findViewById(com.mindvalley.loginmodule.R.id.login_btn_login);
EditText emailEditText = activity.findViewById(com.mindvalley.loginmodule.R.id.login_edittext_email);
EditText passwordEditText = activity.findViewById(com.mindvalley.loginmodule.R.id.login_edittext_password);
emailEditText.setText("harsh@mindvalley.com");
passwordEditText.setText("test123");
loginButton.performClick();
Assert.assertTrue(Util_Auth0.getInstance().getAndroidClient() != null);
// test update prefs method
activity.updatePrefs();
Assert.assertTrue(!PreferenceManager.getBoolean(LoginModule.SKIP_LOGIN, false));
Assert.assertTrue(PreferenceManager.getBoolean(LoginModule.SIGNED_IN, false));
}

@After
public void tearDown() {
activity = null;
}
}

最佳答案

这里有答案

https://github.com/robolectric/robolectric/issues/4591#event-2116260870

这是 stackoverflow 答案的链接 Why are my Gradle builds dying with exit-code 137?

谢谢克里斯蒂安·威廉姆斯

关于android - CircleCI ./gradlew 测试命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54513980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com