Last active
June 19, 2020 17:18
-
-
Save xtreme-steve-elliott/4489ee022ec8982ee9febefab46ba675 to your computer and use it in GitHub Desktop.
IntelliJ Live Templates for generating: - TypeScript describe block with basic test, TestBed and fixture.detectChanges() - JUnit 5 test class w/ display name - JUnit 5 nested class w/ display name, - JUnit 5 test w/ display name. Place it in the `/templates` directory of your IntelliJ and restart.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<templateSet group="Steve's Custom Live Templates"> | |
<template name="cdescr" value="import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; describe($CLASS_NAME$.name, () => { let component: $CLASS_NAME$; let fixture: ComponentFixture<$CLASS_NAME$>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ $CLASS_NAME$ ], providers: [], imports: [ NoopAnimationsModule ] }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent($CLASS_NAME$); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }); " description="Inserts describe() block for a class" toReformat="true" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
<option name="TypeScript" value="true" /> | |
</context> | |
</template> | |
<template name="j5tc" value="import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @DisplayName("$DISPLAY_NAME$") class $CLASS_NAME$ { $END$ }" description="Inserts JUnit 5 Spring extenstion test class with display name" toReformat="false" toShortenFQNames="true"> | |
<variable name="DISPLAY_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="CLASS_NAME" expression="capitalize(camelCase(DISPLAY_NAME))" defaultValue="" alwaysStopAt="false" /> | |
<context> | |
<option name="JAVA_CODE" value="true" /> | |
</context> | |
</template> | |
<template name="tdn" value="@Test @DisplayName("$DISPLAY_NAME$") void $METHOD_NAME$() { $END$ }" description="Inserts JUnit 5 Test with DisplayName" toReformat="false" toShortenFQNames="true"> | |
<variable name="DISPLAY_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD_NAME" expression="camelCase(DISPLAY_NAME)" defaultValue="" alwaysStopAt="false" /> | |
<context> | |
<option name="JAVA_CODE" value="true" /> | |
</context> | |
</template> | |
<template name="ndn" value="@Nested @DisplayName("$DISPLAY_NAME$") class $CLASS_NAME$ { $END$ }" description="Inserts Nested JUnit 5 class with Display Name" toReformat="false" toShortenFQNames="true"> | |
<variable name="DISPLAY_NAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
<variable name="CLASS_NAME" expression="capitalize(camelCase(DISPLAY_NAME))" defaultValue="" alwaysStopAt="false" /> | |
<context> | |
<option name="JAVA_CODE" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment