GithubHelp home page GithubHelp logo

Comments (3)

giurim avatar giurim commented on August 27, 2024 1

from scalatest-junit-runner.

giurim avatar giurim commented on August 27, 2024 1

Hi Gabriel,

I just checked what is going on with this issue. As far as I understand it, this problem falls outside of the scope of the test runner.

The foreach function catches all exceptions and reports them to the execution context. In the javadoc it is described as

Since this method executes asynchronously and does not produce a return value, any non-fatal exceptions thrown will be reported to the ExecutionContext.

The default handler prints a stack-trace but otherwise does nothing else. The type of the ExecutionContext used determines how this error will be handled. Also because of the async execution of the lambda of the foreach, the test itself already finishes with success when the assertions are running.

I think using foreach is not the best approach because of how the error is handled. I am not sure if this is the best solution, but using map instead of foreach and waiting on the result of the assertions broke the test when the assertion did break:

test("should fail future") {
    val future = Future {
      1
    }

    Await.result(
      future.map({ r =>
        r should ===(2)
      }),
      Duration.Inf)
  }

Let me know if you find anything else to handle these assertions.
Best,
Gyuri

from scalatest-junit-runner.

gabrieljones avatar gabrieljones commented on August 27, 2024

After closer examination, I realize that assertions inside of a future.foreach is a definite code smell. Somehow Intellij is able to see the TestFailedException even though it was thrown in some other thread and mark the test failed anyway.

from scalatest-junit-runner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.