IntelliJ 13 code templates
Sample
Ctrl+J them type "that" to get assertThat method from assertj (with static import,...)
or for surround templates :
select a block of code then : Ctrl + Alt + J and type TRY to surround your code with a try {} catch {}
How to get it ?
- Download intellij-templates.zip (which is this repo, but in a zip file)
- In IntelliJ : click on File > Import Settings
- Select the zip you have just downloaded
- Import Live Templates & answer Yes when IntelliJ wants to be restarted
- Enjoy !
![Lives Templates](https://raw.githubusercontent.com/dwursteisen/intellij-templates/master/import.png)
References
Code templates
template |
description |
doThrow | mockito / doThrow ... when |
doReturn | mockito / doReturn...when |
gw | BDD Stub mock with given(…).willReturn(…) style |
wg | BDD Stub spy/mock with willReturn(…).given(…) style |
am | Creates a field with the @Mock annotation |
as | Creates a field with the @Spy annotation |
aim | Creates a field with the @InjectMocks annotation |
rwm | Add @RunWith(MockitoJUnitRunner.class) |
verif | Inserts a verify(…) statement |
ioverif | Inserts Mockito.inOrder(mocks) followed by inOrder.verify(…) statementInserts Mockito.inOrder(mocks) followed by inOrder.verify(…) statement |
template |
description |
that | that / fest assert |
ext | extract property |
filter | filter property |
template |
description |
bf | Creates a setup method |
should | create a junit test |
run_theories | Run With Theories |
should_theory | create theory unit test |
swat | Creates a junit test with assert that |
template |
description |
should_NG | create a test NG unit test |
plain java (surround)
template |
description |
TRY | Surround with Try/Catch |