Add JUnit tests for commands

This commit is contained in:
Louis Calas 2019-10-09 16:18:54 +02:00
parent a8efeb5c18
commit 0d2ad849da
2 changed files with 51 additions and 0 deletions

View File

@ -151,6 +151,7 @@ public class Read implements Callable <Void> {
GestionnaireCopies ocr = new GestionnaireCopies("../"+directory_name);
// Instantie l'ocr
logger.debug("CSV initialized with : "+ocr.createHashMapforCSV()+" , "+config.getParam().get("Code")+" , "+result_name);
GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name);

View File

@ -0,0 +1,50 @@
package commands;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.HelpCommand;
@Command(
name = "TestRead",
version = "Version 1.0",
sortOptions = false,
usageHelpWidth = 60,
header = "\n ---- Nicely Generated and Corrected Copies ---- \n\n" +
" _______ _________________ ________ \n" +
" \\ \\ / _____/\\_ ___ \\\\_ ___ \\ \n" +
" / | \\/ \\ ___/ \\ \\// \\ \\/ \n" +
" / | \\ \\_ \\ \\ \\___\\ \\___ \n" +
" \\____|__ /\\______ /\\______ /\\______ / \n" +
" \\/ \\/ \\/ \\/ \n" +
" \n" ,
footer = "\n\n ---- Provided by IUT Info Nice S3T-G4 ---- \n",
description = ""
)
class TestRead {
@Test
void test() {
Read read = new Read(System.out);
CommandLine cmd = new CommandLine (new TestRead())
.addSubcommand("-r", read)
.addSubcommand("help", new HelpCommand());
String[] t = {"-r","-v9","-d","pdf","config.txt"};
cmd.execute(t);
assertEquals("pdf",read.directory_name);
assertEquals(9,read.vb_level);
assertEquals("config.txt",read.source_path);
assertEquals("result.csv",read.result_name);
}
}