Skip to content

Commit 8dcd4df

Browse files
Remove initial unit test (#5)
* Remove initial unit test * Add comments and update doco to fixt exercise 1 and 2
1 parent 0149773 commit 8dcd4df

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Please run the following to give it execute permissions.
4545
chmod +x ./mvnw
4646
```
4747

48-
### Exercise 1: Write a GET Request
48+
### Exercise 1: Write a "Hello world" GET Request
4949

5050
For this exercise we will be adding a new endpoint to handle a simple GET request.
5151

@@ -60,10 +60,12 @@ You can now run the application and then test it with curl.
6060
2. Test with curl: `curl -v http://localhost:8080/hello?key=world`
6161
3. If you are using GitHub `Codespaces`, replace localhost:8080 with actual `Codespaces` url.
6262

63-
### Exercise 2: Write a Test Case
63+
### Exercise 2: Write a "Hello world" Test Case
6464

65-
There is an existing unit test `src/test/.../CopilotDemoApplicationTests.java`, run below command to test it.
65+
Navigate to `src/test/.../CopilotDemoApplicationTests.java`, to start writing your first test.
6666

67+
- Just press enter and wait a couple of seconds, Copilot will generate the code for you.
68+
- Alternatively, you can test the Copilot inline feature by pressing `ctrl/⌘ + i`. Then write in the text box the desired behaviour.
6769
- run `./mvnw test`
6870
- If the test passed you should see something like this:
6971

copilot-demo/mvnw

100644100755
File mode changed.

copilot-demo/src/main/java/com/microsoft/hackathon/copilotdemo/controller/DemoController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.springframework.web.bind.annotation.RestController;
66

77
/*
8-
* Create a GET operation to return the value of a key passed as query parameter.
8+
* Create a /hello GET operation to return the value of a key passed as query parameter.
99
* If the key is not passed, return "key not passed".
1010
* If the key is passed, return "hello <key>".
1111
*

copilot-demo/src/test/java/com/microsoft/hackathon/copilotdemo/CopilotDemoApplicationTests.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
99
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;;
1010

11-
1211
@SpringBootTest()
13-
@AutoConfigureMockMvc
12+
@AutoConfigureMockMvc
1413
class CopilotDemoApplicationTests {
1514

16-
@Autowired
17-
private MockMvc mockMvc;
15+
@Autowired
16+
private MockMvc mockMvc;
1817

19-
@Test
20-
void hello() throws Exception {
21-
mockMvc.perform(MockMvcRequestBuilders.get("/hello?key=world"))
22-
.andExpect(MockMvcResultMatchers.status().isOk())
23-
.andExpect(MockMvcResultMatchers.content().string("hello world"));
24-
}
18+
// Create a test to check if the /hello GET operation that accepts key as query parameter and returns "hello <key>" is working correctly.
2519

2620
}

0 commit comments

Comments
 (0)