尝试使用带有gradle的junit 5:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0'
}
}
apply plugin: 'java-library'
apply plugin: 'org.junit.platform.gradle.plugin'
...
Run Code Online (Sandbox Code Playgroud)
错误:
Plugin with id 'org.junit.platform.gradle.plugin' not found.
Run Code Online (Sandbox Code Playgroud)
Gradle版本4.0.怎么了?
如何仅运行测试用例的一种方法以使用 Gradle 进行调试?我试过了:
gradle test -tests example.TestFoo#testMethod1 --debug-jvm
Run Code Online (Sandbox Code Playgroud)
但最终出现以下错误:
No tests found for given includes: example.TestFoo#testMethod1
Run Code Online (Sandbox Code Playgroud)
测试TestFoo类有testMethod1(),testMethod2()等等。
def mergedCompileClasspath == null
project.sourceSets.each {
if (mergedCompileClasspath == null)
mergedCompileClasspath = it.compileClasspath
else
mergedCompileClasspath .plus(it.compileClasspath)
}
Run Code Online (Sandbox Code Playgroud)
plus() 方法不起作用。compileClassPath 是不可变的?如何创建一个空的fileCollection?
Android已连接AndroidTest:未找到测试
gradle :aar-lib:connectedAndroidTest
com.android.builder.testing.ConnectedDevice > No tests found.
FAILED No tests found. This usually means that your test classes
are not in the form that your test runner expects (e.g. don't
inherit from TestCase or lack @Test annotations).
Run Code Online (Sandbox Code Playgroud)
测试类别:
@RunWith(AndroidJUnit4.class)
public class FooTest {
@Test
public void testFoo() {
....
}
}
Run Code Online (Sandbox Code Playgroud)
看着测试APK,它包含测试类。
java方法返回类型不是实际类型.例如,
public interface Foo<X extends TypeA> {
public X hello();
}
public class Bar implements Foo<TypeB> {
@Override
public TypeB hello() {
...
}
}
Method method = Bar.class.getDeclaredMethod("hello");
Class returnType = method.getReturnType();
Run Code Online (Sandbox Code Playgroud)
returnType是TypeA,不是TypeB. TypeB是.的子类TypeA.
如何获取方法的实际返回类型?它TypeB不是TypeA.
我用了
Method[] methods = Bar.class.getDeclaredMethods();
Run Code Online (Sandbox Code Playgroud)
然后遍历这些方法.该方法返回超类.验证getDeclaredMethod("hello")确实返回子类类型.他们为什么不同?
android 测试支持风格和构建类型变体?
flavorDimensions "foo"
productFlavors {
full {
dimension "foo"
}
trial {
dimension "foo"
}
}
Run Code Online (Sandbox Code Playgroud)
如果只有 src/androidTest/java,要测试哪个变体?
Gradle Android 测试不支持过滤器(--tests)。
gradlew test --tests com.example.test.*
Run Code Online (Sandbox Code Playgroud)
作品。
gradlew connectedAndroidTest --tests com.example.test.*
Run Code Online (Sandbox Code Playgroud)
错误:未知的命令行选项“--tests”。
对于序列化,将排除瞬态字段.克隆有没有类似的关键词?如何从克隆中排除字段?
public class Foo implements Cloneable {
private Integer notInClone;
}
Run Code Online (Sandbox Code Playgroud) Oracle存储过程具有OUT参数并返回结果集,例如
create or replace procedure foo(empId IN NUMBER, maxSalary OUT NUMBER) AS BEGIN
select * from Employee e where e.id >=empId;
select max(salary) into maxSalary from Employee;
END;
Run Code Online (Sandbox Code Playgroud)
错误:
PLS-00428: an INTO clause is expected in this SELECT statement
Run Code Online (Sandbox Code Playgroud)
Mysql存储过程可以返回结果集和输出参数.如何为oracle db做到这一点?
mysql jdbc:
resultSet.getInt(index)
Run Code Online (Sandbox Code Playgroud)
为 NULL 返回 0,因为它的返回类型是 int,而不是 java.lang.Integer。但
resultSet.getObject(index, java.lang.Long)
Run Code Online (Sandbox Code Playgroud)
为空返回 0。它应该返回NULL。对?检查结果集的列类型,列类型为java.lang.Long。它应该返回空值,但为空值返回 0。
检查 Oracle 11g:它按预期返回 null。
“ EST”是TimeZone.getAvailableIDs()中的timeZone ID之一。
但
TimeZone.getAvailableIDs(); // contains EST
ZoneId.of("EST")
Run Code Online (Sandbox Code Playgroud)
java.time.zone.ZoneRulesException:未知的时区ID:EST