Skip to content

Commit b3720eb

Browse files
authored
add support of scala 2.13 for allure-scalatest (via allure-framework#433)
1 parent cb906b9 commit b3720eb

13 files changed

Lines changed: 52 additions & 48 deletions

File tree

allure-scalatest/build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ description = "Allure ScalaTest Integration"
44

55
apply(plugin = "scala")
66

7-
val availableScalaVersions = listOf("2.11", "2.12")
7+
val availableScalaVersions = listOf("2.11", "2.12", "2.13")
88
val defaultScala211Version = "2.11.12"
99
val defaultScala212Version = "2.12.8"
10+
val defaultScala213Version = "2.13.1"
1011

11-
var selectedScalaVersion = defaultScala212Version
12+
var selectedScalaVersion = defaultScala213Version
1213

1314
if (hasProperty("scalaVersion")) {
1415
val scalaVersion: String by project
1516
selectedScalaVersion = when (scalaVersion) {
1617
"2.11" -> defaultScala211Version
1718
"2.12" -> defaultScala212Version
19+
"2.13" -> defaultScala213Version
1820
else -> scalaVersion
1921
}
2022
}
@@ -81,7 +83,8 @@ val agent: Configuration by configurations.creating
8183
dependencies {
8284
agent("org.aspectj:aspectjweaver")
8385
api(project(":allure-java-commons"))
84-
implementation("org.scalatest:scalatest_$baseScalaVersion:3.0.5")
86+
implementation("org.scalatest:scalatest_$baseScalaVersion:3.1.1")
87+
implementation("org.scala-lang.modules:scala-collection-compat_$baseScalaVersion:2.1.4")
8588
testAnnotationProcessor(project(":allure-descriptions-javadoc"))
8689
testImplementation("io.github.glytching:junit-extensions")
8790
testImplementation("org.assertj:assertj-core")

allure-scalatest/src/main/scala/io/qameta/allure/scalatest/AllureScalatest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.scalatest.Reporter
2727
import org.scalatest.events._
2828
import org.scalatest.exceptions.TestFailedException
2929

30-
import scala.collection.JavaConverters._
30+
import scala.jdk.CollectionConverters._
3131
import scala.collection.mutable
3232

3333
/**
@@ -185,7 +185,7 @@ class AllureScalatest(val lifecycle: AllureLifecycle) extends Reporter {
185185
createLanguageLabel("scala"),
186186
createFrameworkLabel("scalatest")
187187
)
188-
labels ++= asScalaSet(getProvidedLabels)
188+
labels ++= getProvidedLabels.asScala
189189

190190
var links = mutable.ListBuffer[io.qameta.allure.model.Link]()
191191

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/AllureScalatestTest.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import io.qameta.allure.scalatest.testdata._
2121
import io.qameta.allure.test.{AllureResults, AllureResultsWriterStub}
2222
import io.qameta.allure.{Allure, AllureLifecycle}
2323
import org.junit.jupiter.api.Test
24-
import org.scalatest.Matchers._
24+
import org.scalatest.matchers.should.Matchers._
2525
import org.scalatest.tools.Runner
2626

27-
import scala.collection.JavaConverters._
2827
import scala.collection.mutable.ListBuffer
28+
import scala.jdk.CollectionConverters._
2929

3030
/**
3131
* @author charlie (Dmitry Baev).
@@ -35,15 +35,15 @@ class AllureScalatestTest {
3535
@Test
3636
def shouldSetName(): Unit = {
3737
val results = run(classOf[SimpleSpec])
38-
asScalaBuffer(results.getTestResults)
38+
results.getTestResults.asScala
3939
.map(item => item.getName) should contain("test should be passed")
4040
}
4141

4242
@Test
4343
def shouldSetStart(): Unit = {
4444
val results = run(classOf[SimpleSpec])
4545

46-
val starts = asScalaBuffer(results.getTestResults)
46+
val starts = results.getTestResults.asScala
4747
.map(item => item.getStart).toList
4848

4949
every(starts) should not be null
@@ -53,7 +53,7 @@ class AllureScalatestTest {
5353
def shouldSetStop(): Unit = {
5454
val results = run(classOf[SimpleSpec])
5555

56-
val stops = asScalaBuffer(results.getTestResults)
56+
val stops = results.getTestResults.asScala
5757
.map(item => item.getStop)
5858

5959
every(stops) should not be null
@@ -63,7 +63,7 @@ class AllureScalatestTest {
6363
def shouldSetStage(): Unit = {
6464
val results = run(classOf[SimpleSpec])
6565

66-
val stages = asScalaBuffer(results.getTestResults)
66+
val stages = results.getTestResults.asScala
6767
.map(item => item.getStage)
6868

6969
every(stages) shouldBe FINISHED
@@ -73,7 +73,7 @@ class AllureScalatestTest {
7373
def shouldSetStatus(): Unit = {
7474
val results = run(classOf[SimpleSpec])
7575

76-
val statuses = asScalaBuffer(results.getTestResults)
76+
val statuses = results.getTestResults.asScala
7777
.map(item => item.getStatus)
7878

7979
every(statuses) shouldBe Status.PASSED
@@ -85,7 +85,7 @@ class AllureScalatestTest {
8585

8686
results.getTestResults should have length 1
8787

88-
val statuses = asScalaBuffer(results.getTestResults)
88+
val statuses = results.getTestResults.asScala
8989
.map(item => item.getStatus)
9090

9191
every(statuses) shouldBe Status.FAILED
@@ -97,7 +97,7 @@ class AllureScalatestTest {
9797

9898
results.getTestResults should have length 1
9999

100-
val statuses = asScalaBuffer(results.getTestResults)
100+
val statuses = results.getTestResults.asScala
101101
.map(item => item.getStatus).toList
102102

103103
every(statuses) should be(Status.BROKEN)
@@ -109,7 +109,7 @@ class AllureScalatestTest {
109109

110110
results.getTestResults should have length 1
111111

112-
val statuses = asScalaBuffer(results.getTestResults)
112+
val statuses = results.getTestResults.asScala
113113
.map(item => item.getStatus).toList
114114

115115
every(statuses) should be(Status.SKIPPED)
@@ -121,8 +121,8 @@ class AllureScalatestTest {
121121

122122
results.getTestResults should have length 1
123123

124-
val labels = asScalaBuffer(results.getTestResults)
125-
.flatMap(item => asScalaBuffer(item.getLabels))
124+
val labels = results.getTestResults.asScala
125+
.flatMap(item => item.getLabels.asScala)
126126
.map(label => (label.getName, label.getValue))
127127
.toList
128128

@@ -138,8 +138,8 @@ class AllureScalatestTest {
138138

139139
results.getTestResults should have length 1
140140

141-
val labels = asScalaBuffer(results.getTestResults)
142-
.flatMap(item => asScalaBuffer(item.getLabels))
141+
val labels = results.getTestResults.asScala
142+
.flatMap(item => item.getLabels.asScala)
143143
.map(label => (label.getName, label.getValue))
144144
.toList
145145

@@ -152,15 +152,15 @@ class AllureScalatestTest {
152152

153153
results.getTestResults should have length 1
154154

155-
asScalaBuffer(results.getTestResults)
155+
results.getTestResults.asScala
156156
.map(item => item.getName) should contain("test should be ignored")
157157

158-
val statuses = asScalaBuffer(results.getTestResults)
158+
val statuses = results.getTestResults.asScala
159159
.map(item => item.getStatus).toList
160160

161161
every(statuses) should be(null)
162162

163-
val stages = asScalaBuffer(results.getTestResults)
163+
val stages = results.getTestResults.asScala
164164
.map(item => item.getStage).toList
165165

166166
every(stages) should be(Stage.FINISHED)
@@ -169,14 +169,14 @@ class AllureScalatestTest {
169169
@Test
170170
def shouldSupportJavaApi(): Unit = {
171171
val results = run(classOf[AllureApiSpec])
172-
val steps = asScalaBuffer(results.getTestResults)
173-
.flatMap(item => asScalaBuffer(item.getSteps))
172+
val steps = results.getTestResults.asScala
173+
.flatMap(item => item.getSteps.asScala)
174174

175175
steps
176176
.map(step => step.getName) should contain inOrder("first", "second", "third")
177177

178178
steps.filter(step => step.getName == "second")
179-
.flatMap(step => asScalaBuffer(step.getSteps))
179+
.flatMap(step => step.getSteps.asScala)
180180
.map(step => step.getName) should contain inOrder("child1", "child2", "child3")
181181

182182
}

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/AllureApiSpec.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ package io.qameta.allure.scalatest.testdata
1717

1818
import io.qameta.allure.Allure.{StepContext, step}
1919
import io.qameta.allure.scalatest.AllureScalatestContext
20-
import org.scalatest.FlatSpec
20+
import org.scalatest.flatspec.AnyFlatSpec
2121

2222
/**
2323
* @author charlie (Dmitry Baev).
2424
*/
25-
class AllureApiSpec extends FlatSpec {
25+
class AllureApiSpec extends AnyFlatSpec {
2626

2727
"test" should "be passed" in new AllureScalatestContext {
2828
step("first")
2929
step("second", () => {
3030
step("child1")
3131
step("child2")
3232
step("child3")
33-
Unit
33+
() =>
3434
})
3535
step("third", (context: StepContext) => {
3636
val a = context.parameter("a", 123L)
3737
val b = context.parameter("b", "hello")
38-
Unit
38+
() =>
3939
})
4040
}
4141

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/AnnotationsOnClassSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package io.qameta.allure.scalatest.testdata
1717

1818
import io.qameta.allure._
19-
import org.scalatest.FunSuite
19+
import org.scalatest.funsuite.AnyFunSuite
2020

2121
/**
2222
* @author charlie (Dmitry Baev).
@@ -28,7 +28,7 @@ import org.scalatest.FunSuite
2828
@Link("https://example.org")
2929
@Issue("https://example.org/issue/1")
3030
@TmsLink("https://example.org/tms/1")
31-
class AnnotationsOnClassSpec extends FunSuite {
31+
class AnnotationsOnClassSpec extends AnyFunSuite {
3232

3333
test("demo test") {
3434
}

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/BrokenSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package io.qameta.allure.scalatest.testdata
1717

18-
import org.scalatest.FlatSpec
19-
import org.scalatest.Matchers._
18+
import org.scalatest.matchers.should.Matchers._
19+
import org.scalatest.flatspec.AnyFlatSpec
2020

2121
/**
2222
* @author charlie (Dmitry Baev).
2323
*/
24-
class BrokenSpec extends FlatSpec {
24+
class BrokenSpec extends AnyFlatSpec {
2525

2626
"test" should "be failed" in {
2727
throw new RuntimeException("hell no")

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/CancelledSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package io.qameta.allure.scalatest.testdata
1717

18-
import org.scalatest.FlatSpec
19-
import org.scalatest.Matchers._
18+
import org.scalatest.flatspec.AnyFlatSpec
19+
import org.scalatest.matchers.should.Matchers._
2020

2121
/**
2222
* @author charlie (Dmitry Baev).
2323
*/
24-
class CancelledSpec extends FlatSpec {
24+
class CancelledSpec extends AnyFlatSpec {
2525

2626
"test" should "be cancelled" in {
2727
cancel("hell yes")

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/FailedSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package io.qameta.allure.scalatest.testdata
1717

18-
import org.scalatest.FlatSpec
19-
import org.scalatest.Matchers._
18+
import org.scalatest.flatspec.AnyFlatSpec
19+
import org.scalatest.matchers.should.Matchers._
2020

2121
/**
2222
* @author charlie (Dmitry Baev).
2323
*/
24-
class FailedSpec extends FlatSpec {
24+
class FailedSpec extends AnyFlatSpec {
2525

2626
"test" should "be failed" in {
2727
"hello" shouldBe "hell no"

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/IgnoredSpec.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
*/
1616
package io.qameta.allure.scalatest.testdata
1717

18-
import org.scalatest.{FlatSpec, Ignore}
18+
import org.scalatest.flatspec.AnyFlatSpec
19+
import org.scalatest.Ignore
1920

2021
/**
2122
* @author charlie (Dmitry Baev).
2223
*/
2324
@Ignore
24-
class IgnoredSpec extends FlatSpec {
25+
class IgnoredSpec extends AnyFlatSpec {
2526

2627
"test" should "be ignored" in {
2728
}

allure-scalatest/src/test/scala/io/qameta/allure/scalatest/testdata/SeveritySpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
package io.qameta.allure.scalatest.testdata
1717

1818
import io.qameta.allure.{Severity, SeverityLevel}
19-
import org.scalatest.FlatSpec
19+
import org.scalatest.flatspec.AnyFlatSpec
2020

2121
/**
2222
* @author charlie (Dmitry Baev).
2323
*/
2424
@Severity(SeverityLevel.BLOCKER)
25-
class SeveritySpec extends FlatSpec {
25+
class SeveritySpec extends AnyFlatSpec {
2626

2727
"test" should "be passed" in {
2828
}

0 commit comments

Comments
 (0)