Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exabrial/619bec6db903aa4d89d005a35614e8ff to your computer and use it in GitHub Desktop.
Save exabrial/619bec6db903aa4d89d005a35614e8ff to your computer and use it in GitHub Desktop.
Regular Expression to Match Junit4 "expected=" tests and convert them to Junit5 "assertThrows()->" tests in Eclipse

Search for this in Eclipse:

(?s)\t@Test\(expected = (\w+\.class)\)\r?\n\tpublic void (test\w+\(\)) (?:throws \w*Exception )?\{(\r?\n\t\t.*?\r?\n\t)\}\r?\n

Replace with the following:

\t@Test public void $2 {assertThrows($1, () -> {$3});}\n\n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment