Git Product home page Git Product logo

Comments (5)

bvenners avatar bvenners commented on May 21, 2024

Hi Tobias,

Sorry I only today noticed this issue. The problem is actually that you put your assertion in a "scope" not a "test". This is unfortunately not a type error, and unfortunately the error message you get in the exception doesn't seem to give much clue. I think what I'll do for the next release is try and give a better hint in the error message. I'll also look at ways to make this kind of error a compile-time error.

Anyway, in a FreeSpec "scopes" are introduced with a dash (-) and "tests" are introduced with "in". Scopes are a way to group tests. Although the bodies of the tests are registered at construction time for later execution, the bodies of scopes are evaluated at construction time. That means in this case your assertions execute at construction time, and when they fail, it means ScalaTest can't instantiate the Suite and so the run aborts. To fix it you can just change the "-" to an "in".

from scalatest.

lefou avatar lefou commented on May 21, 2024

Thanks for you explanation. Unfortunately, I'm not quite sure I understand it. You said, the assert is not in a "test", but actually, it is surrounded by a "string" in { .. } construct. Also, the assert will not throw an exception in the case the code is right, but still I see this issue.

Why I can get rid of the exception, when I delete the toString() override in the class under test?

Also, if I remove the third of these test cases (constructed with the mergeTest function, so my understanding is, it is a "test") all other tests run well. Even if I now modify the class under test so that it produces incorrect results, I still get a proper test run outlining the successful ran and the failed tests.

from scalatest.

bvenners avatar bvenners commented on May 21, 2024

Sorry, I didn't notice the "in". This one is back in action.

from scalatest.

bvenners avatar bvenners commented on May 21, 2024

Ah, duplicate test name exception was being thrown!

from scalatest.

lefou avatar lefou commented on May 21, 2024

Thank you Bill for taking the time (live @ ScalaDays) to look into this!

(The strange three cases from the original issue (overridden toString, removed feature, removed test case) all influenced the titles of the tests and thus implicitly avoided the duplication.)

from scalatest.

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.