holdenk / holdenk/spark-testing-base

Misleading error when comparing resutls

Open
#269 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
1.6k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

When running a test if the test fails, it will stay that 'Array' did not equal 'List'. While the important part is that the elements do not match.
To reproduce the issue please run the following test

```
import org.scalatest.{FlatSpec, Matchers}
import com.holdenkarau.spark.testing.StreamingSuiteBase
import org.apache.spark.streaming.dstream.DStream

object TestFunctions {

def doSomeOperation(input: DStream[String]): DStream[String] = input.map { i =>
i + "x"
}
}

class MisleadingErrorTest extends FlatSpec with Matchers with StreamingSuiteBase {

"DoSomeOperation" should "map String values to a well format string" in {

val input = List(List("{ \"userId\": 1}"))

val expectedL = List(List("{ \"userId\": 1}"))

testOperation(input, TestFunctions.doSomeOperation, expectedL)
}
}
```

This produce the following error
`[info] - should map String values to a well format string *** FAILED ***
[info] Array("{ "userId": 1}x") did not equal List("{ "userId": 1}") (StreamingSuiteBase.scala:105)
`

The message should say List(...) did not match List(...) or Array(...) did not match Array.

Contributor guide

Open the contributing guide

Research direction

Start at StreamingSuiteBase.scala:105, where the reported comparison error is produced, and reproduce it with the MisleadingErrorTest example from the issue. Check how the compared values are represented in the failure message. Done means the message reports matching collection types, such as List(...) did not match List(...) or Array(...) did not match Array(...).

Written by the indexing model from the issue text.

Assessment

Tech stack
scala, spark
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.