Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom matchers for testing #212

Closed
jserranohidalgo opened this issue Apr 26, 2022 · 0 comments · Fixed by #219
Closed

Custom matchers for testing #212

jserranohidalgo opened this issue Apr 26, 2022 · 0 comments · Fixed by #219
Labels
enhancement New feature or request good first issue Good for newcomers testing

Comments

@jserranohidalgo
Copy link
Member

Testing might be improved with custom matchers.

For instance, instead of:

  val df = List((User("John", "doe", 34), 1))
      .toDF("col", "delete")
      .select("col")
  ...
   it("throws an error if the sub column is not of the provided type") {
      colStruct("col")
        .getChild[String]("age")
        .elem
        .run(df)
        .toEither
        .left
        .value
        .head shouldBe ColumnTypeError("col.age", StringType, IntegerType)

it'd be nice to write something like this:

   it("..."){
      df.select(colStruct("col").getChild[String]("age")) should 
          failWith(ColumnTypeError("col.age", StringType, IntegerType))
   }

In general, testing should not expose implementation details, and stick itself to the programmer API whenever possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant