即使在 Android Studio 上使用错误断言值,单元测试也总是通过?

问题描述

即使在 Android Studio 上使用错误的断言值,单元测试也始终通过,例如在编写此方法时它通过了

"C:\Program Files\Android\Android Studio\jre\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\Android\Android Studio\lib\idea_rt.jar=53441:C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Amin\AppData\Local\Temp\classpath152820636.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 (package.....).ApiServiceTest,testAssert
    
    Process finished with exit code 0

enter image description here

我不知道为什么会发生这种情况,我检查了我的测试配置是否有问题,但我认为没有问题

enter image description here

这里是运行测试的完整构建打印

> Configure project :app
WARNING: API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information,see TBD.
To determine what is calling BaseVariant.getApplicationIdTextResource,use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'com.github.bumptech.glide:compiler:
4.12.0'.

BUILD SUCCESSFUL in 5s
90 actionable tasks: 90 up-to-date

在终端中使用 gradle/app:test 我得到了这个

vari = 15
vari_name = f"{vari=}".split("=")[0]
print(vari_name)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)