Multiplatform test annotations
Actual annotations are provided in kotlin-test-junit on JVM side and in kotlin-test-js on JS side. #KT-19696
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
description = 'Kotlin Test Annotations Common'
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
configurePublishing(project)
|
||||||
|
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(':kotlin-stdlib-common')
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifestAttributes(manifest, project, 'Test')
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
classifier = 'sources'
|
||||||
|
from sourceSets.main.kotlin
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
archives javadocJar
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.test
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a function as a test.
|
||||||
|
*/
|
||||||
|
public expect annotation class Test()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a test or a suite as ignored.
|
||||||
|
*/
|
||||||
|
public expect annotation class Ignore()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a function to be invoked before each test.
|
||||||
|
*/
|
||||||
|
public expect annotation class BeforeTest()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a function to be invoked after each test.
|
||||||
|
*/
|
||||||
|
public expect annotation class AfterTest()
|
||||||
@@ -7,6 +7,7 @@ configurePublishing(project)
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':kotlin-stdlib-common')
|
compile project(':kotlin-stdlib-common')
|
||||||
|
testCompile project(":kotlin-test:kotlin-test-annotations-common")
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
package org.junit
|
package org.junit
|
||||||
|
|
||||||
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||||
|
@Deprecated("Use 'Test' from kotlin.test package",
|
||||||
|
replaceWith = ReplaceWith("kotlin.test.Test", "kotlin.test.Test"),
|
||||||
|
level = DeprecationLevel.WARNING)
|
||||||
expect annotation class Test()
|
expect annotation class Test()
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kotlin.test.tests
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
private var value = 5
|
||||||
|
|
||||||
|
class AnnotationsTest {
|
||||||
|
|
||||||
|
@BeforeTest fun setup() {
|
||||||
|
value *= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest fun teardown() {
|
||||||
|
value /= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testValue() {
|
||||||
|
assertEquals(10, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testValueAgain() {
|
||||||
|
assertEquals(10, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore @Test fun testValueWrong() {
|
||||||
|
assertEquals(20, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package kotlin.test.tests
|
package kotlin.test.tests
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
class BasicAssertionsTest {
|
class BasicAssertionsTest {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ apply plugin: 'kotlin-platform-js'
|
|||||||
configurePublishing(project)
|
configurePublishing(project)
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implement project(':kotlin-test:kotlin-test-common')
|
expectedBy project(':kotlin-test:kotlin-test-common')
|
||||||
|
compile project(':kotlin-test:kotlin-test-annotations-common') // TODO: replace with impl-dependency
|
||||||
compile project(':kotlin-stdlib-js')
|
compile project(':kotlin-stdlib-js')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.junit
|
package org.junit
|
||||||
|
|
||||||
@Deprecated("Use 'Test' from kotlin.test package",
|
@Deprecated("Use 'Test' from kotlin.test package",
|
||||||
replaceWith = ReplaceWith("Test", "kotlin.test.Test"),
|
replaceWith = ReplaceWith("kotlin.test.Test", "kotlin.test.Test"),
|
||||||
level = DeprecationLevel.WARNING)
|
level = DeprecationLevel.WARNING)
|
||||||
actual typealias Test = kotlin.test.Test
|
actual typealias Test = kotlin.test.Test
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
description = 'Kotlin Test JUnit'
|
description = 'Kotlin Test JUnit'
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
configureJvm6Project(project)
|
configureJvm6Project(project)
|
||||||
configurePublishing(project)
|
configurePublishing(project)
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
expectedBy project(':kotlin-test:kotlin-test-annotations-common')
|
||||||
compile project(':kotlin-test:kotlin-test-jvm')
|
compile project(':kotlin-test:kotlin-test-jvm')
|
||||||
compile('junit:junit:4.12')
|
compile('junit:junit:4.12')
|
||||||
}
|
}
|
||||||
@@ -26,7 +27,7 @@ dist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-module-name", project.name]
|
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xmulti-platform", "-module-name", project.name]
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
|
@file:JvmPackageName("kotlin.test.annotations")
|
||||||
|
package kotlin.test
|
||||||
|
|
||||||
|
public actual typealias Test = org.junit.Test
|
||||||
|
public actual typealias Ignore = org.junit.Ignore
|
||||||
|
public actual typealias BeforeTest = org.junit.Before
|
||||||
|
public actual typealias AfterTest = org.junit.After
|
||||||
@@ -7,8 +7,9 @@ configureJvm6Project(project)
|
|||||||
configurePublishing(project)
|
configurePublishing(project)
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implement project(':kotlin-test:kotlin-test-common')
|
expectedBy project(':kotlin-test:kotlin-test-common')
|
||||||
compile project(':kotlin-stdlib')
|
compile project(':kotlin-stdlib')
|
||||||
|
testCompile project(":kotlin-test:kotlin-test-junit")
|
||||||
testCompile('junit:junit:4.12')
|
testCompile('junit:junit:4.12')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package kotlin.test.tests
|
package kotlin.test.tests
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import org.junit.*
|
|
||||||
|
|
||||||
class BasicAssertionsJVMTest {
|
class BasicAssertionsJVMTest {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
@file:Suppress("DEPRECATION")
|
@file:Suppress("DEPRECATION")
|
||||||
package kotlin.test.tests
|
package kotlin.test.tests
|
||||||
|
|
||||||
import org.junit.*
|
import org.junit.Assert
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package kotlin.test.tests
|
package kotlin.test.tests
|
||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
class TestJVMTest {
|
class TestJVMTest {
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ include ":kotlin-build-common",
|
|||||||
":kotlin-script-runtime",
|
":kotlin-script-runtime",
|
||||||
":kotlin-runtime",
|
":kotlin-runtime",
|
||||||
":kotlin-test:kotlin-test-common",
|
":kotlin-test:kotlin-test-common",
|
||||||
|
":kotlin-test:kotlin-test-annotations-common",
|
||||||
":kotlin-test:kotlin-test-jvm",
|
":kotlin-test:kotlin-test-jvm",
|
||||||
":kotlin-test:kotlin-test-junit",
|
":kotlin-test:kotlin-test-junit",
|
||||||
":kotlin-test:kotlin-test-js",
|
":kotlin-test:kotlin-test-js",
|
||||||
@@ -147,6 +148,7 @@ rootProject.name = "kotlin"
|
|||||||
project(':kotlin-runtime').projectDir = "$rootDir/libraries/tools/runtime" as File
|
project(':kotlin-runtime').projectDir = "$rootDir/libraries/tools/runtime" as File
|
||||||
project(':kotlin-script-runtime').projectDir = "$rootDir/libraries/tools/script-runtime" as File
|
project(':kotlin-script-runtime').projectDir = "$rootDir/libraries/tools/script-runtime" as File
|
||||||
project(':kotlin-test:kotlin-test-common').projectDir = "$rootDir/libraries/kotlin.test/common" as File
|
project(':kotlin-test:kotlin-test-common').projectDir = "$rootDir/libraries/kotlin.test/common" as File
|
||||||
|
project(':kotlin-test:kotlin-test-annotations-common').projectDir = "$rootDir/libraries/kotlin.test/annotations-common" as File
|
||||||
project(':kotlin-test:kotlin-test-jvm').projectDir = "$rootDir/libraries/kotlin.test/jvm" as File
|
project(':kotlin-test:kotlin-test-jvm').projectDir = "$rootDir/libraries/kotlin.test/jvm" as File
|
||||||
project(':kotlin-test:kotlin-test-junit').projectDir = "$rootDir/libraries/kotlin.test/junit" as File
|
project(':kotlin-test:kotlin-test-junit').projectDir = "$rootDir/libraries/kotlin.test/junit" as File
|
||||||
project(':kotlin-test:kotlin-test-js').projectDir = "$rootDir/libraries/kotlin.test/js" as File
|
project(':kotlin-test:kotlin-test-js').projectDir = "$rootDir/libraries/kotlin.test/js" as File
|
||||||
|
|||||||
Reference in New Issue
Block a user