Skip to content

Commit 8258edf

Browse files
committed
update docs
1 parent 89b69df commit 8258edf

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Extension to help write Java tests.
1212

1313
### Create Test File
1414

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.
15+
Generate a test class in the folder `src/test/java` with code to construct the source class, if already there is a test
16+
class then it will be opened.
1617

1718
Example:
1819

@@ -21,9 +22,6 @@ Given the file `/src/main/java/com/github/sample/MessageService.java`:
2122
```java
2223
package com.github.sample;
2324

24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
26-
2725
public class MessageService {
2826
public String getMessage() {
2927
return "Hello World!";
@@ -63,8 +61,9 @@ public class MessageServiceTest {
6361

6462
## Todos
6563

66-
- [ ] Create tests
64+
- [ ] Create tests for the extension
6765
- [ ] Generate a test case for each method
66+
- [ ] Command to create the target class in `src/main/java` when doing TDD
6867

6968
## Links
7069

src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,21 @@ async function createTestClass() {
3232

3333
try {
3434
await vscode.workspace.fs.stat(testFileUri);
35-
vscode.window.showTextDocument(testFileUri, { viewColumn: vscode.ViewColumn.Beside });
35+
showTestFile(testFileUri);
3636

3737
} catch {
3838
const fileContent = generateTestClassFileContent(javaFileUri, javaClassName, testFileUri, testClassName);
3939
await vscode.workspace.fs.writeFile(testFileUri, fileContent);
4040

41-
vscode.window.showTextDocument(testFileUri, { viewColumn: vscode.ViewColumn.Beside });
41+
showTestFile(testFileUri);
4242
}
4343
}
4444

45+
function showTestFile(testFileUri: vscode.Uri) {
46+
// TODO: extract configuration to define where to open it: beside (new editor group) or current editor group
47+
vscode.window.showTextDocument(testFileUri, { viewColumn: vscode.ViewColumn.Beside });
48+
}
49+
4550
function getTestFileUri(javaFileUri: vscode.Uri, testClassName: string) {
4651
const testPath = javaFileUri.path.replace('/src/main/java', '/src/test/java');
4752
const testFilePath = posix.join(testPath, '..', `${testClassName}.java`);

0 commit comments

Comments
 (0)