question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception during macro expansion in mockito-scala-scalatest

See original GitHub issue

Context (Environment)

Running unit tests with following dependencies:

  • Scala v2.11.12
  • Gradle v5.6
  • mockito-scala-scalatest_2.11 v1.14.3
  • scalatest_2.11 v3.0.5
  • spark-sql_2.11 v2.4.3

Here is the test script:

import org.mockito.scalatest.MockitoSugar

class MyTest extends FunSuite with MockitoSugar {

  test("should return something") {
    // given
    val mySpy = spy(new MySpy)
    when(mySpy.doSomething(any, any)).thenReturn(new DataFrame(...))

    // when
    val actual = mySpy.myMethod("some-string")

    // then
    val expected = new DataFrame(...)
    assert(expected === actual)

Expected Behavior

Tests should be running without any exceptions thrown.

Current Behavior

Failed to load ApplicationContext while initializing embedded database.

Error:(43, 11) exception during macro expansion: 
java.lang.NoSuchMethodError: org.scalactic.BooleanMacro.<init>(Lscala/reflect/macros/whitebox/Context;Ljava/lang/String;)V
	at org.scalatest.AssertionsMacro$.assert(AssertionsMacro.scala:34)
    assert(expected === actual)

Assumption

Dependency conflicts

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bbonannocommented, May 30, 2020

you’r assumption was right, you’re using an old version of Scalatest, update to “3.1.2” and the problem goes away

0reactions
goytia54commented, Mar 2, 2021

I just wanted to add my resolution to this issue when changing from strictly mockito-core to mockito-scala. I had to add "org.scalactic" %% "scalactic" % "3.0.3" % "test" to my dependencyOverrides. I am not currently able to update scalatest past 3.0.4 and am on scala version 2.11.12

Read more comments on GitHub >

github_iconTop Results From Across the Web

exception during macro expansion error with openjdk11, sbt ...
I'm receiving a lot of errors [error] /root/something-updates/src/main/scala/Something.scala:67:92: exception during macro expansion: ...
Read more >
exception during macro expansion - Google Groups
Hi Chung, I think you hit the problem between Scala 2.11.2 and our assert macro. Scala 2.11.2 has some kind of incompatible change...
Read more >
`exception during macro expansion: [error] scala.reflect ...
I am already requiring ctx as an implicit variable, so I can't import it as well. You don't need to import a context...
Read more >
getquill/quill - Gitter
I'm getting exception during macro expansion: [error] java.lang.InstantiationError: com.typesafe.scalalogging.Logger [error] at com.typesafe.scalalogging.
Read more >
Macro expansion - Guide to Rustc Development
With few exceptions, we use this method on the whole crate (see "Eager Expansion" below for more detailed discussion of edge case expansion...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found