Skip to content

Commit

Permalink
Update Scalatest to 3.1.1 and run Scalafix
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Mauch authored and nightscape committed Dec 11, 2021
1 parent 9aeb963 commit 92d461e
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 39 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ val coreTestSources = unmanagedSourceDirectories in Test := {

// additional libraries
lazy val commonDependencies = Seq(
"org.scalatest" %% "scalatest" % "3.0.8",
"org.scalatest" %% "scalatest" % "3.1.1",
"org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2",
"io.github.nicolasstucki" %% "multisets" % "0.4",
"org.scalacheck" %% "scalacheck" % "1.14.0",
"junit" % "junit" % "4.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import org.apache.spark._
import org.apache.spark.rdd.RDD
import org.apache.spark.SparkContext._

import org.scalatest.FunSuite
import org.scalatest.exceptions.TestFailedException
import org.scalatest.funsuite.AnyFunSuite

/**
* ArtisinalStreamingTest illustrates how to write a streaming test
Expand All @@ -36,7 +36,7 @@ import org.scalatest.exceptions.TestFailedException
* This does not use a manual clock and instead uses the kind of sketchy
* sleep approach. Instead please look at [[SampleStreamingTest]].
*/
class ArtisinalStreamingTest extends FunSuite with SharedSparkContext {
class ArtisinalStreamingTest extends AnyFunSuite with SharedSparkContext {
// tag::createQueueStream[]
def makeSimpleQueueStream(ssc: StreamingContext) = {
val input = List(List("hi"), List("happy pandas", "sad pandas"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.holdenkarau.spark.testing
import org.apache.spark.sql.{Dataset, SQLContext}
import org.scalacheck.{Gen, Arbitrary}
import org.scalacheck.Prop.forAll
import org.scalatest.FunSuite
import org.scalatestplus.scalacheck.Checkers
import org.apache.spark.sql.SparkSession
import org.scalatest.funsuite.AnyFunSuite

class DatasetGeneratorSizeSpecial extends FunSuite
class DatasetGeneratorSizeSpecial extends AnyFunSuite
with SharedSparkContext with Checkers {

test("test generating sized Datasets[Custom Class]") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import org.apache.spark.ml.linalg.SQLDataTypes.{MatrixType, VectorType}
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.types.{StructField, StructType}
import org.scalacheck.Prop.forAll
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.apache.spark.sql.SparkSession

class MLScalaCheckTest extends FunSuite with SharedSparkContext with Checkers {
class MLScalaCheckTest extends AnyFunSuite with SharedSparkContext with Checkers {
// re-use the spark context
override implicit def reuseContextIfPossible: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.holdenkarau.spark.testing

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class MultipleDataFrameSuites extends FunSuite with DataFrameSuiteBase {
class MultipleDataFrameSuites extends AnyFunSuite with DataFrameSuiteBase {
test("test nothing") {
assert(1 === 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package com.holdenkarau.spark.testing

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

/**
* Illustrate using per-test sample test. This is the one to use
* when your tests may be destructive to the Spark context
* (e.g. stopping it)
*/
class PerTestSampleTest extends FunSuite with PerTestSparkContext {
class PerTestSampleTest extends AnyFunSuite with PerTestSparkContext {

test("sample test stops a context") {
sc.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package com.holdenkarau.spark.testing
import java.nio.file.Files

import org.apache.spark._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

/**
* Illustrate using per-test sample test. This is the one to use
* when your tests may be destructive to the Spark context
* (e.g. stopping it)
*/
class PerTestSparkContextTest extends FunSuite with PerTestSparkContext {
class PerTestSparkContextTest extends AnyFunSuite with PerTestSparkContext {
val tempPath = Files.createTempDirectory(null).toString()

//tag::samplePerfTest[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package com.holdenkarau.spark.testing
import java.nio.file.Files

import org.apache.spark._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

/**
* Illustrate using per-test sample test. This is the one to use
* when your tests may be destructive to the Spark context
* (e.g. stopping it)
*/
class PerfSampleTest extends FunSuite with PerTestSparkContext {
class PerfSampleTest extends AnyFunSuite with PerTestSparkContext {
val tempPath = Files.createTempDirectory(null).toString()

//tag::samplePerfTest[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructT
import org.scalacheck.Gen
import org.scalacheck.Prop._
import org.scalacheck.util.Pretty
import org.scalatest.FunSuite
import org.scalatest.exceptions.GeneratorDrivenPropertyCheckFailedException
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.apache.spark.sql.SparkSession

class PrettifyTest extends FunSuite with SharedSparkContext with Checkers with Prettify {
implicit val propertyCheckConfig = PropertyCheckConfig(minSize = 2, maxSize = 2)
class PrettifyTest extends AnyFunSuite with SharedSparkContext with Checkers with Prettify {
implicit val propertyCheckConfig = PropertyCheckConfiguration(minSize = 2, sizeRange = 0)

test("pretty output of DataFrame's check") {
val schema = StructType(List(StructField("name", StringType), StructField("age", IntegerType)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import java.sql.Timestamp

import org.apache.spark.sql.{DataFrame, Row}
import org.apache.spark.sql.types._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class SampleDataFrameTest extends FunSuite with DataFrameSuiteBase {
class SampleDataFrameTest extends AnyFunSuite with DataFrameSuiteBase {
val byteArray = new Array[Byte](1)
val diffByteArray = Array[Byte](192.toByte)
val inputList = List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.holdenkarau.spark.testing
import org.apache.spark.sql.{Dataset, SQLContext}
import org.scalacheck.{Gen, Arbitrary}
import org.scalacheck.Prop.forAll
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.apache.spark.sql.SparkSession

class SampleDatasetGeneratorTest extends FunSuite
class SampleDatasetGeneratorTest extends AnyFunSuite
with SharedSparkContext with Checkers {

test("test generating Datasets[String]") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.holdenkarau.spark.testing

import java.sql.Timestamp

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class SampleDatasetTest extends FunSuite with DatasetSuiteBase {
class SampleDatasetTest extends AnyFunSuite with DatasetSuiteBase {

test("equal empty dataset") {
import sqlContext.implicits._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package com.holdenkarau.spark.testing

import org.apache.spark.rdd.RDD
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

// Commented out because it's a pain to run in CI with different versions and @Ignore doesn't do the trick.
/*
class SampleMiniClusterTest extends FunSuite with SharedMiniCluster {
class SampleMiniClusterTest extends AnyFunSuite with SharedMiniCluster {
test("really simple transformation") {
val input = List("hi", "hi holden", "bye")
val expected = List(List("hi"), List("hi", "holden"), List("bye"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package com.holdenkarau.spark.testing
import scala.util.Random

import org.apache.spark.rdd.RDD
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class SampleRDDTest extends FunSuite with SharedSparkContext with RDDComparisons {
class SampleRDDTest extends AnyFunSuite with SharedSparkContext with RDDComparisons {
test("really simple transformation") {
val input = List("hi", "hi holden", "bye")
val expected = List(List("hi"), List("hi", "holden"), List("bye"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import org.apache.spark.sql.{DataFrame, Row, SQLContext}
import org.apache.spark.sql.types._
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Prop.forAll
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.scalacheck.Checkers
import org.apache.spark.sql.SparkSession

class SampleScalaCheckTest extends FunSuite
class SampleScalaCheckTest extends AnyFunSuite
with SharedSparkContext with RDDComparisons with Checkers {
// tag::propertySample[]
// A trivial property that the map doesn't change the number of elements
Expand Down Expand Up @@ -258,7 +258,7 @@ class SampleScalaCheckTest extends FunSuite

test("generate rdd of specific size") {
implicit val generatorDrivenConfig =
PropertyCheckConfig(minSize = 10, maxSize = 20)
PropertyCheckConfiguration(minSize = 10, sizeRange = 10)
val prop = forAll(RDDGenerator.genRDD[String](sc)(Arbitrary.arbitrary[String])){
rdd => rdd.count() <= 20
}
Expand Down Expand Up @@ -372,7 +372,7 @@ class SampleScalaCheckTest extends FunSuite

test("second dataframe's evaluation has the same values as first") {
implicit val generatorDrivenConfig =
PropertyCheckConfig(minSize = 1, maxSize = 1)
PropertyCheckConfiguration(minSize = 1, sizeRange = 0)

val sqlContext = SparkSession.builder.getOrCreate().sqlContext
val dataframeGen =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import org.apache.spark._
import org.apache.spark.util.LongAccumulator
import org.apache.spark.rdd.RDD
import org.apache.spark.streaming.dstream._
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class SampleStreamingActionTest extends FunSuite with StreamingActionBase {
class SampleStreamingActionTest extends AnyFunSuite with StreamingActionBase {

test("a simple action") {
val input = List(List("hi"), List("bye"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import org.apache.spark.streaming.Seconds
import org.apache.spark.streaming.dstream._
import org.scalactic.Equality
import org.scalatest.exceptions.TestFailedException
import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class SampleStreamingTest extends FunSuite with StreamingSuiteBase {
class SampleStreamingTest extends AnyFunSuite with StreamingSuiteBase {

//tag::simpleStreamingTest[]
test("really simple transformation") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package com.holdenkarau.spark.testing
import java.io._
import java.nio.file.Files

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class UtilsTest extends FunSuite {
class UtilsTest extends AnyFunSuite {
test("test utils cleanup") {
val tempDir = Utils.createTempDir()
val tempPath = tempDir.toPath().toAbsolutePath().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.holdenkarau.spark.testing

import org.apache.spark.sql._

import org.scalatest.FunSuite
import org.scalatest.funsuite.AnyFunSuite

class StructuredStreamingTests
extends FunSuite with SharedSparkContext with StructuredStreamingBase {
extends AnyFunSuite with SharedSparkContext with StructuredStreamingBase {
// re-use the spark context
override implicit def reuseContextIfPossible: Boolean = true

Expand Down

0 comments on commit 92d461e

Please sign in to comment.