masooh / intellij-junit-to-spock-converter

JUnit to Spock Converter IntelliJ Plugin: Converts JUnit to Spock. See https://plugins.jetbrains.com/plugin/12335-groovyfier
MIT License
8 stars 3 forks source link

Support conversion of verify ... times #28

Open rojyates opened 3 years ago

rojyates commented 3 years ago

Conversion Request

I would like the plugin to replace verify ... times:

verify(getTransactionsPolicy, times(2)).validateAccess(org.mockito.ArgumentMatchers.any())

with

2 * getTransactionsPolicy.validateAccess(_)

I would like the plugin to replace verify ... never:

verify(getTransactionsPolicy, never()).validateAccess(org.mockito.ArgumentMatchers.any())

with

0 * getTransactionsPolicy.validateAccess(_)

Regex

I currently use the following regex search for the times(..) pattern:

verify\((\w+),\s*times\((\w+)\)\)\.(.*\))

and replace:

$2 * $1.$3

I currently use the following regex search for the never() pattern:

verify\((\w+),\s*never\(\)\)\.(.*\))

and replace:

0 * $1.$2
leonard84 commented 3 years ago

Just a site note, this probably has to be joined if there is a matching when-return as Spock combines these statements into one.