我正在使用 IntelliJ IDEA Multiplatform 项目,而 jsTest Gradle 任务未检测到任何测试。jvmTest 测试运行没有问题。当我运行带有调试输出的 jsTest 任务时,我可以看到该任务运行并立即完成。
Gradle 版本 4.10.1。Kotlin 版本 1.3.0-eap。
如何纠正 Gradle 配置,或者我可以运行什么命令,以便实际检测到测试,并且(如所写)失败?
构建.gradle:
plugins {
id 'kotlin-multiplatform' version '1.3.0-rc-131'
}
repositories {
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral()
}
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
}
commonTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-common'
implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common'
}
}
jvmMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}
}
jvmTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
jsMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
}
}
jsTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test-js'
}
}
}
}
测试项目_test.js:
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'test-project_test'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'test-project_test'.");
}
if (typeof this['test-project'] === 'undefined') {
throw new Error("Error loading module 'test-project_test'. Its dependency 'test-project' was not found. Please, check whether 'test-project' is loaded prior to 'test-project_test'.");
}
if (typeof this['kotlin-test'] === 'undefined') {
throw new Error("Error loading module 'test-project_test'. Its dependency 'kotlin-test' was not found. Please, check whether 'kotlin-test' is loaded prior to 'test-project_test'.");
}
this['test-project_test'] = function (_, Kotlin, $module$test_project, $module$kotlin_test) {
'use strict';
var Sample = $module$test_project.sample.Sample;
var assertTrue = $module$kotlin_test.kotlin.test.assertTrue_ifx8ge$;
var Kind_CLASS = Kotlin.Kind.CLASS;
var hello = $module$test_project.sample.hello;
var contains = Kotlin.kotlin.text.contains_li3zpu$;
var test = $module$kotlin_test.kotlin.test.test;
var suite = $module$kotlin_test.kotlin.test.suite;
function SampleTests() {
}
SampleTests.prototype.testMe = function () {
assertTrue((new Sample()).checkMe() > 0);
};
SampleTests.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'SampleTests',
interfaces: []
};
function SampleTestsJS() {
}
SampleTestsJS.prototype.testHello = function () {
assertTrue(contains(hello(), 'JSSDF'));
};
SampleTestsJS.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'SampleTestsJS',
interfaces: []
};
var package$sample = _.sample || (_.sample = {});
package$sample.SampleTests = SampleTests;
package$sample.SampleTestsJS = SampleTestsJS;
suite('sample', false, function () {
suite('SampleTests', false, function () {
test('testMe', false, function () {
return (new SampleTests()).testMe();
});
});
suite('SampleTestsJS', false, function () {
test('testHello', false, function () {
return (new SampleTestsJS()).testHello();
});
});
});
Kotlin.defineModule('test-project_test', _);
return _;
}(typeof this['test-project_test'] === 'undefined' ? {} : this['test-project_test'], kotlin, this['test-project'], this['kotlin-test']);