Giter Site home page Giter Site logo

masooh / intellij-junit-to-spock-converter Goto Github PK

View Code? Open in Web Editor NEW
8.0 5.0 3.0 272 KB

JUnit to Spock Converter IntelliJ Plugin: Converts JUnit to Spock. See https://plugins.jetbrains.com/plugin/12335-groovyfier

License: MIT License

Java 12.74% Kotlin 87.26%
intellij-plugin spock junit

intellij-junit-to-spock-converter's Introduction

JUnit to Spock Converter

GitHub Actions Build Pipeline
Build Status
Lines of Code

JUnit to Spock Converter is a plug-in for IntelliJ IDEA: https://plugins.jetbrains.com/plugin/12335-groovyfier.

It’s inspired by junit2spock and has the same goal: Facilitate the transition from JUnit to Spock. The advantage compared to the command line tool is the integration in the IDE. The project is in an early stage and has at the moment only a subset of the features of junit2spock.

After converting your JUnit test to a spock specification it probably will not be 100% correct, but it will save you a lot of stupid conversion work.

Features

The following can be replaced:

Table 1. test method → feature method

JUnit 4 / 5

Spock

@Test
public void assertOnly() {
    assertNotNull(book);
}
def "assert only"() {
    expect:
    book != null
}
Table 2. Replace Setup/Cleanup annotations

JUnit 4 / 5

Spock

@BeforeClass / @BeforeAll
public static void beforeClass() { }

@AfterClass / @AfterAll
public static void afterClass() { }

@Before / @BeforeEach
public void setUp() { }

@After / @AfterEach
public void tearDown() { }
def setupSpec() { }

def cleanupSpec() { }

def setup() { }

def cleanup() { }
Table 3. Replace assertions, messages convert to comments

JUnit 4 / 5

Spock

assertNotNull(book);
assertNull(book.getPages());
assertEquals((Integer) 33, book.getPages());
assertTrue(book.getPages() > 0);
assertFalse(book.getPages() < 0);
assertNotNull("book is present", book);
book != null
book.pages == null
book.pages == (Integer) 33
book.pages > 0
!(book.pages < 0)
book != null // "book is present"
Table 4. Expected exceptions → thrown

JUnit 4 (only)

Spock

@Test(expected = IllegalArgumentException.class)
public void expectArgumentException() {
    book.setPages(-1);
}
def "expect argument exception"() {
    when:
    book.pages = -1
    then:
    thrown(IllegalArgumentException)
}

Limitations

The following is not (yet) possible:

Roadmap

  • Documentation

    • Commit converted test to show what works and what not: BookTest

    • Plugin description with small video like IntelliJ new features

  • Quality

    • Unit Tests for plugin itself

  • Separate code, so that it can be easily extended with new features and it’s easier to provide pull requests.

  • Framework support

    • Mockito

    • Wicket

    • Hamcrest

  • Spock features

    • create data driven tests if test contains only similar assertions

intellij-junit-to-spock-converter's People

Contributors

dependabot[bot] avatar leonard84 avatar masooh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

intellij-junit-to-spock-converter's Issues

Reuse given/when/then comments

If the Junit test has given/when/then comments these should be used as labels for the spock test.

@Test
public void givenWhenThen() {
    // given
    Book bookToTest = new Book();

    // when
    bookToTest.setTitle("title");

    // then
    assertEquals("title", bookToTest.getTitle());
}

Improve Code Style

Exactly one empty line between labels

Currently when -> then: no empty line, then -> when: 2 empty lines

No empty line must be left behind from former annotations

Deal with inheritance

Currently, the extension always extends from Specification, but since multiple inheritance is illegal this will run into problems when transforming a test class that inherits from a base class. In this case, the converter could either stop with an error message or offer to convert the base class as well.

public class A {
 @Test
 public void aTest() {
 // some code
 }
}

public class B extends A {
 @Test
 public void bTest() {
 // some code
 }
}

Transforms into

public class A extends Specification {
 def "a test"() {
 // some code
 }
}

public class B extends A {
 def "b test"() {
 // some code
 }
}

Error '... already exists in VFS' when converting java class to groovy

Describe the bug

When you have a java class in the groovy source set and convert it to groovy, then it fails

To Reproduce

Create a java class in src/test/groovy then use the Convert Java to Groovy action.

Expected behavior

No exception happens.

Actual behavior

java.io.IOException: '<...>/spock/spock-guice/src/test/groovy/org/spockframework/guice/IService3.groovy' already exists in VFS
	at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.moveFile(LocalFileSystemBase.java:474)
	at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.moveFile(PersistentFSImpl.java:804)
	at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.lambda$move$1(VirtualFileSystemEntry.java:327)
	at com.intellij.openapi.vfs.encoding.EncodingRegistry.doActionAndRestoreEncoding(EncodingRegistry.java:54)
	at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.move(VirtualFileSystemEntry.java:326)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper$renameAndMoveToGroovy$1.run(JavaToGroovyFileHelper.kt:118)
	at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:86)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:935)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:961)
	at com.intellij.openapi.application.WriteAction.run(WriteAction.java:85)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.renameAndMoveToGroovy(JavaToGroovyFileHelper.kt:105)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.access$renameAndMoveToGroovy(JavaToGroovyFileHelper.kt:19)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper$createGroovyRootAndMoveFile$1.run(JavaToGroovyFileHelper.kt:31)
	at com.intellij.openapi.project.DumbServiceImpl.doUnsafeRunWhenSmart(DumbServiceImpl.java:259)
	at com.intellij.openapi.project.DumbServiceImpl.lambda$runWhenSmart$0(DumbServiceImpl.java:243)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runAfterOpened(StartupManagerImpl.kt:448)
	at com.intellij.openapi.project.DumbServiceImpl.runWhenSmart(DumbServiceImpl.java:243)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.createGroovyRootAndMoveFile(JavaToGroovyFileHelper.kt:30)
	at com.github.masooh.intellij.plugin.junitspock.action.ConvertJavaToGroovy.actionPerformed(ConvertJavaToGroovy.kt:37)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:244)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:265)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:244)
	at com.intellij.ide.actions.GotoActionAction.performActionImpl(GotoActionAction.java:111)
	at com.intellij.ide.actions.GotoActionAction.lambda$performAction$2(GotoActionAction.java:84)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Environment:

IntelliJ version

IntelliJ IDEA 2021.3.1 (Ultimate Edition)
Build #IU-213.6461.79, built on December 28, 2021
Runtime version: 11.0.13+7-b1751.21 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.1
GC: G1 Young Generation, G1 Old Generation
Memory: 8192M
Cores: 16
Non-Bundled Plugins:
com.github.masooh.intellij.plugin.groovyfier (0.2)

Support `assertThat` transformations

This can be a two step approach.

Spock has spock.util.matcher.HamcrestSupport so the basic approach would be to replace the assertThat invocations with
the that() (in expect-blocks) or expect() (in then-blocks) methods of Hamcrest-support.

In a second iteration, the matchers could be analyzed and replaced if there is a simple Spock equivalent, e.g.,
assertThat(x, is("ok")) would be x == "ok", and assertThat(x, is(not("ok"))) would be x != "ok".

Support conversion of verify ... times

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

PluginException: `ActionUpdateThread.OLD_EDT` is deprecated and going to be removed soon

Describe the bug

IntelliJ reports this error

com.intellij.diagnostic.PluginException: `ActionUpdateThread.OLD_EDT` is deprecated and going to be removed soon. 'com.github.masooh.intellij.plugin.junitspock.action.ConvertJavaToGroovy' must override `getActionUpdateThread` and chose EDT or BGT. See ActionUpdateThread javadoc. [Plugin: com.github.masooh.intellij.plugin.groovyfier]
	at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
	at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:90)
	at com.intellij.diagnostic.PluginException.reportDeprecatedUsage(PluginException.java:125)
	at com.intellij.openapi.actionSystem.ActionUpdateThreadAware.getActionUpdateThread(ActionUpdateThreadAware.java:21)
	at com.intellij.openapi.actionSystem.AnAction.getActionUpdateThread(AnAction.java:199)

To Reproduce

Open a recent Intellij version

IntelliJ version

IntelliJ IDEA 2024.1 (Ultimate Edition)
Build #IU-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.4.1
GC: G1 Young Generation, G1 Old Generation
Memory: 12288M
Cores: 12
Metal Rendering is ON
Non-Bundled Plugins:
  com.github.masooh.intellij.plugin.groovyfier (0.2)
Kotlin: 241.14494.240-IJ

Support conversion of when().thenReturn(), and any() matchers

Conversion Request

I would like the plugin to replace

Mockito.when(myClass.method(any(), any())).thenReturn(someData);

or

import static org.mockito.Mockito.when;

when(myClass.method(any(), any())).thenReturn(someData);

with

  myClass.method(_, _) >> someData

Regex

I currently use the following regex search for the when/thenReturn:

when\((.*)\)[\n\r\s]*\.thenReturn\((.*)\)

with replace:

$1 >> $2

and search for the any() matcher:

any\(\)

with replace:

_

Support conversion of assertDoesNotThrow()

Conversion Request

I would like the plugin to replace

assertDoesNotThrow(() -> service.getData("Id", "param"))

or

assertDoesNotThrow(() -> {
            service.getData("Id", "param")
        })

with

when: "we execute our test"
service.getData("Id", "param")

then: "no Exception was thrown"
notThrown(Exception)

Add more issue templates

Currently the only issue template is for a conversion request, IMHO there should be some additional templates:

  • Bug Report
  • Feature Request

Exception when converting java to groovy when java file is already in groovy directory

In mixed java/groovy code bases it is common to have the java files in the groovy source root, so that cross compilation works.

When converting such a java file, this exception happens, because the file is already in the correct location and can't be moved.

java.io.IOException: 'C:/Users/hidden/workspaces/github/geb-testcontainers-videos-per-test/src/main/groovy/org/gebish/actionlog/ReportTracingInterceptor.groovy' already exists in VFS
	at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.moveFile(LocalFileSystemBase.java:445)
	at com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl.moveFile(PersistentFSImpl.java:811)
	at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.lambda$move$1(VirtualFileSystemEntry.java:327)
	at com.intellij.openapi.vfs.encoding.EncodingRegistry.doActionAndRestoreEncoding(EncodingRegistry.java:57)
	at com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry.move(VirtualFileSystemEntry.java:326)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper$renameAndMoveToGroovy$1.run(JavaToGroovyFileHelper.kt:118)
	at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:105)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:947)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:973)
	at com.intellij.openapi.application.WriteAction.run(WriteAction.java:104)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.renameAndMoveToGroovy(JavaToGroovyFileHelper.kt:105)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.access$renameAndMoveToGroovy(JavaToGroovyFileHelper.kt:19)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper$createGroovyRootAndMoveFile$1.run(JavaToGroovyFileHelper.kt:31)
	at com.intellij.openapi.project.DumbServiceImpl.doUnsafeRunWhenSmart(DumbServiceImpl.java:258)
	at com.intellij.openapi.project.DumbServiceImpl.lambda$runWhenSmart$0(DumbServiceImpl.java:244)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runAfterOpened(StartupManagerImpl.java:503)
	at com.intellij.openapi.project.DumbServiceImpl.runWhenSmart(DumbServiceImpl.java:244)
	at com.github.masooh.intellij.plugin.junitspock.JavaToGroovyFileHelper.createGroovyRootAndMoveFile(JavaToGroovyFileHelper.kt:30)
	at com.github.masooh.intellij.plugin.junitspock.action.ConvertJavaToGroovy.actionPerformed(ConvertJavaToGroovy.kt:37)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAware$5(ActionUtil.java:273)
	at com.intellij.util.SlowOperations.lambda$allowSlowOperations$0(SlowOperations.java:77)
	at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:64)
	at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:76)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:273)
	at com.intellij.ide.actions.GotoActionAction.lambda$performAction$2(GotoActionAction.java:108)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:218)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:200)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:319)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:969)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:839)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Support conversion of mock(X.class)

Conversion Request

I would like the plugin to replace

import static org.mockito.Mockito.mock
...
criteriaBuilderMock = mock(CriteriaBuilder.class)

with

criteriaBuilderMock = Mock(CriteriaBuilder)

Support conversion of when().thenThrow()

Conversion Request

I would like the plugin to replace

when(repository.findAll(any(Pageable.class)).thenThrow(CannotCreateTransactionException.class)
when(repository.findAll(any(Specification.class), any(Pageable.class))).thenThrow(CannotCreateTransactionException.class)

with

repository.findAll(_ as Pageable) >> { throw new CannotCreateTransactionException("test") }
repository.findAll(_ as Specification, _ as Pageable)) >> { throw new CannotCreateTransactionException("test") }

Regex

I currently use the following regex search:

when\(([\w\.]+)\(([\w,\s]+)\)\)[\r\n\s]*.thenThrow\((.*)(?:\.class)\)

and replace:

$1($2) >> { throw new $3("test") }

Convert Lambda to Closure

Lambda cannot be used in Groovy and has to be converted.

@Test
void expectArgumentException() {
    Assertions.assertThrows(IllegalArgumentException.class, () -> book.setPages(-1),
                            "Negative page number must fail");

}

There is already an intention which needs to be triggered: org.jetbrains.plugins.groovy.annotator.intentions.ConvertLambdaToClosureAction

Support assertThrows() conversion, with and without variable declaration

Conversion Request

I would like the plugin to replace

Exception exception = assertThrows(MyCustomException.class, () -> validator.validateInput(someData));

or, when split across lines:

Exception exception = assertThrows(MyCustomException.class, 
    () -> validator.validateInput(someData));

with

 when: "we execute our test"
 validator.validateInput(someData)

 then: "a MyCustomException was thrown"
 Exception exception = thrown(MyCustomException)

and, for the case where the exception is not captured as a variable, replace:

assertThrows(MyCustomException.class, () -> validator.validateInput(someData));

or, when split across lines:

assertThrows(MyCustomException.class, 
    () -> validator.validateInput(someData));

with

 when: "we execute our test"
 validator.validateInput(someData)

 then: "a MyCustomException was thrown"
 thrown(MyCustomException)

Regex

Here's the Regex that I currently use for the first case search:

([\w\.]+\s*\w+)\s*=\s*assertThrows\((\w+)(?:.class),[\(\)\{\r\n\s]+->(.*)[\}]*\)

and for the replace template:

when: "we execute our test"\n$3\n\n then: "a $2 was thrown"\n $1 = thrown($2)\n

Here's the Regex that I currently use for the second case search:

assertThrows\((\w+)(?:.class),[\(\)\{\r\n\s]+->(.*)[\}]*\)

and for the replace template:

when: "we execute our test"\n$2\n\n then: "a $1 was thrown"\n thrown($1)\n

Support conversion of assertDoesNotThrow()

Conversion Request

I would like the plugin to replace

assertDoesNotThrow(() -> {
            validator.validate(data)
        })

or

assertDoesNotThrow(() -> validator.validate(data))

with

when: "we execute our test"
validator.validate(data)

then: "no Exception was thrown"
notThrown(Exception)

Links

If open source, please add additionally a link to the real example

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.