Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#37: Extract ConsoleRunner logic into ConsoleTasks
- Better separation of concerns - Better testability
- Loading branch information
1 parent
7e1e67e
commit f0dfe1f
Showing
9 changed files
with
224 additions
and
127 deletions.
There are no files selected for viewing
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
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
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
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
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
28 changes: 28 additions & 0 deletions
28
junit-console/src/main/java/org/junit/gen5/console/tasks/ConsoleTask.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2015 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v1.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.junit.gen5.console.tasks; | ||
|
||
import java.io.PrintWriter; | ||
|
||
/** | ||
* A task to be executed from the console. | ||
*/ | ||
public interface ConsoleTask { | ||
|
||
/** | ||
* Execute this task and return an exit code. | ||
* | ||
* @param out writer for console output | ||
* @return exit code indicating success ({@code 0}) or failure ({@code != 0}) | ||
*/ | ||
int execute(PrintWriter out) throws Exception; | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
junit-console/src/main/java/org/junit/gen5/console/tasks/DisplayHelpTask.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2015 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v1.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.junit.gen5.console.tasks; | ||
|
||
import java.io.PrintWriter; | ||
|
||
import org.junit.gen5.console.options.CommandLineOptionsParser; | ||
|
||
public class DisplayHelpTask implements ConsoleTask { | ||
|
||
private final CommandLineOptionsParser parser; | ||
|
||
public DisplayHelpTask(CommandLineOptionsParser parser) { | ||
this.parser = parser; | ||
} | ||
|
||
@Override | ||
public int execute(PrintWriter out) { | ||
parser.printHelp(new PrintWriter(out)); | ||
return 0; | ||
} | ||
|
||
} |
Oops, something went wrong.