-
Notifications
You must be signed in to change notification settings - Fork 27
#345: Replace ExitGuard in integration tests #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7f7546f
#345: Add Jar Launcher
kaklakariada a6a114d
Fix starting stream consumer
kaklakariada ec4ba39
Merge remote-tracking branch 'origin/main' into kaklakariada/issue345
kaklakariada bf77419
Add builder for JarLauncher
kaklakariada 42740d6
Convert test to integration test
kaklakariada e79f0f3
Test with latest Java 24
kaklakariada 1976464
Remove ExitGuard annotations
kaklakariada ee88f30
Adapt tests to Java > 21
kaklakariada ff7b6bd
Fix integration tests
kaklakariada 4368244
Fix integration tests
kaklakariada b45e034
Improve test assertions
kaklakariada 03a2870
Enable broken tests
kaklakariada 887aaca
Simplify JarLauncher API
kaklakariada b8ddf25
Fix sonar warnings
kaklakariada 7723ac3
Merge branch 'main' into kaklakariada/issue345
kaklakariada 6bf24e9
Adapt integration test under windows
kaklakariada 515b381
Fix mockito agent warning
kaklakariada a739ccc
Define ossindex credentials
kaklakariada 87a916f
Upgrade dependencies
kaklakariada 4fdeeae
Upgrade test dependencies
kaklakariada dfc1e17
Fix ossindex credentials
kaklakariada b4054f1
Add debug output for failing test
kaklakariada 0eb1cc7
Add helpful output to assertion message
kaklakariada 1cc04a9
Fix integration test for windows
kaklakariada 545e206
Implement review findings
kaklakariada b944622
Fix vscode setup
kaklakariada 40efb83
Get aggregated dependency update PRs
kaklakariada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,4 +30,4 @@ public CliException(final String message) | |
| { | ||
| super(message); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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
56 changes: 0 additions & 56 deletions
56
core/src/test/java/org/itsallcode/openfasttrace/core/cli/TestCliStarter.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
112 changes: 112 additions & 0 deletions
112
product/src/test/java/org/itsallcode/openfasttrace/cli/CliExitIT.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| package org.itsallcode.openfasttrace.cli; | ||
|
|
||
| import static java.util.Collections.emptyList; | ||
| import static org.hamcrest.Matchers.*; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.*; | ||
|
|
||
| import org.itsallcode.openfasttrace.core.cli.ExitStatus; | ||
| import org.itsallcode.openfasttrace.core.cli.commands.TraceCommand; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| class CliExitIT | ||
| { | ||
| private static final String TEST_RESOURCES_MARKDOWN = "../core/src/test/resources/markdown"; | ||
| private static final String SAMPLE_DESIGN = TEST_RESOURCES_MARKDOWN + "/sample_design.md"; | ||
| private static final String SAMPLE_SYSTEM_REQUIREMENTS = TEST_RESOURCES_MARKDOWN | ||
| + "/sample_system_requirements.md"; | ||
|
|
||
| @Test | ||
| void testRunWithoutArguments() | ||
| { | ||
| jarLauncher() | ||
| .args(emptyList()) | ||
| .expectedExitCode(ExitStatus.CLI_ERROR.getCode()) | ||
| .expectStdOut(emptyString()) | ||
| .expectStdErr(equalTo("oft: Missing command\nAdd one of 'help','convert','trace'\n\n")) | ||
| .verify(); | ||
| } | ||
|
|
||
| @Test | ||
| void testRunWithUnsupportedCommand() | ||
| { | ||
| jarLauncher() | ||
| .args(List.of("unsupported")) | ||
| .expectedExitCode(ExitStatus.CLI_ERROR.getCode()) | ||
| .expectStdOut(emptyString()) | ||
| .expectStdErr(equalTo( | ||
| "oft: 'unsupported' is not an OFT command.\nChoose one of 'help','convert','trace'.\n\n")) | ||
| .verify(); | ||
| } | ||
|
|
||
| @Test | ||
| void testRunWithHelpCommand() | ||
| { | ||
| jarLauncher() | ||
| .args(List.of("help")) | ||
| .expectedExitCode(ExitStatus.OK.getCode()) | ||
| .expectStdOut(startsWith(""" | ||
| OpenFastTrace | ||
|
|
||
| Usage: | ||
| oft command""")) | ||
kaklakariada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .expectStdErr(emptyString()) | ||
| .verify(); | ||
| } | ||
|
|
||
| @Test | ||
| void testRunWithUnsupportedReporter(@TempDir final Path emptyDir) | ||
| { | ||
| jarLauncher() | ||
| .args(List.of("trace", "-o", "unknown", emptyDir.toString())) | ||
| .expectedExitCode(ExitStatus.FAILURE.getCode()) | ||
| .expectStdOut(emptyString()) | ||
| .expectStdErr(startsWith( | ||
| "Exception in thread \"main\" org.itsallcode.openfasttrace.api.exporter.ExporterException: Found no matching reporter for output format 'unknown'")) | ||
| .verify(); | ||
| } | ||
|
|
||
| @Test | ||
| void testCliExitCode_Ok() | ||
| { | ||
| assertExitStatusForTracedFiles(ExitStatus.OK, SAMPLE_SYSTEM_REQUIREMENTS, SAMPLE_DESIGN); | ||
| } | ||
|
|
||
| private void assertExitStatusForTracedFiles(final ExitStatus expectedStatus, final String... files) | ||
| { | ||
| final List<String> args = new ArrayList<>(); | ||
| args.add(TraceCommand.COMMAND_NAME); | ||
| args.addAll(Arrays.asList(files)); | ||
| jarLauncher() | ||
| .args(args) | ||
| .expectedExitCode(expectedStatus.getCode()) | ||
| .expectStdErr(emptyString()) | ||
| .expectStdOut(not(emptyString())) | ||
| .verify(); | ||
| } | ||
|
|
||
| private JarLauncher.Builder jarLauncher() | ||
| { | ||
| return JarLauncher.builder() | ||
| .currentWorkingDir(); | ||
| } | ||
|
|
||
| @Test | ||
| void testCliExitCode_Failure() | ||
| { | ||
| assertExitStatusForTracedFiles(ExitStatus.FAILURE, SAMPLE_SYSTEM_REQUIREMENTS); | ||
| } | ||
|
|
||
| @Test | ||
| void testCliExitCode_CliError() | ||
| { | ||
| jarLauncher() | ||
| .args(List.of("--zzzz")) | ||
| .expectedExitCode(ExitStatus.CLI_ERROR.getCode()) | ||
| .expectStdOut(emptyString()) | ||
| .expectStdErr(equalTo("oft: Unexpected parameter '--zzzz' is not allowed\n")) | ||
kaklakariada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .verify(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.