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

Plugin completely breaks debugging when a function with name "advance()" is defined #53

Open
rgba opened this issue Oct 27, 2017 · 0 comments

Comments

@rgba
Copy link

rgba commented Oct 27, 2017

When you debug a spek test and your class contains a function named "advance()" this method will be called when stepping over function calls in the debugger.

How to reproduce:

  1. Set breakpoint on advance() function call in the for loop
  2. Debug spek test via debug functionality
  3. When the debugger stops you at the breakpoint just hit "F8" to step over all the function calls, for each time you step over a function, advance() will be called an the counter will increase. But this only happens if the debugger view in IntelliJ is visible (the one where you can inspect the stack frames), if you switch to console view during debugging this issue does not occur.
  4. assertion will fail

So far I have found out that the issue has to do with the actual function definition, if I rename the function to something else this is not reproducible.

 import org.jetbrains.spek.api.dsl.given
 import org.jetbrains.spek.api.dsl.it
 import org.jetbrains.spek.api.dsl.on
 import org.junit.Assert.assertEquals

class CounterTest {

  var counter: Int = 0

  fun count(): Int {

    println("Counter initial count: " + counter)
    
    for (i in 1..10) {
      advance()
      println("Current loop iteration count : " + counter)
    }

    return counter
  }

  private fun advance() {
    counter++
  }
}

fun main(args: Array<String>) {
  val counter = CounterTest()
  val finalCount = counter.count()

  assertEquals(10, finalCount)
}

object CounterSpek : Spek({
  given("counter") {

    on("do count to 10") {
      val counter = CounterTest()
      val finalCount = counter.count()

      it("expected final count is 10") {
        assertEquals(10, finalCount)
      }
    }
  }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant