11# VSCode Java Tests
22
3- Extension to help develop Java tests.
3+ Extension to help write Java tests.
44
55## How to Use
66
@@ -12,7 +12,54 @@ Extension to help develop Java tests.
1212
1313### Create Test File
1414
15- Generate a test class with code to construct the source class, if already there is a test class then it will be open.
15+ Generate a test class in the folder ` src/test/java ` with code to construct the source class, if already there is a test class then it will be open.
16+
17+ Example:
18+
19+ Given the file ` /src/main/java/com/github/sample/MessageService.java ` :
20+
21+ ``` java
22+ package com.github.sample ;
23+
24+ import org.slf4j.Logger ;
25+ import org.slf4j.LoggerFactory ;
26+
27+ public class MessageService {
28+ public String getMessage () {
29+ return " Hello World!" ;
30+ }
31+ }
32+ ```
33+
34+ Generate the test file ` /src/test/java/com/github/sample/MessageServiceTest.java ` :
35+
36+ ``` java
37+ package com.github.sample ;
38+
39+ import static org.hamcrest.CoreMatchers.* ;
40+ import org.hamcrest.CustomMatcher ;
41+ import org.hamcrest.Matcher ;
42+ import static org.junit.Assert.assertThat ;
43+ import org.junit.Before ;
44+ import org.junit.Test ;
45+
46+ import com.github.sample.MessageService ;
47+
48+ public class MessageServiceTest {
49+ private MessageService cut;
50+
51+ @Before
52+ public void setup () {
53+ this . cut = new MessageService ();
54+ }
55+
56+ @Test
57+ public void shouldCompile () {
58+ assertThat(" Actual value" , is(" Expected value" ));
59+ }
60+ }
61+
62+ ```
1663
1764## Todos
1865
0 commit comments