From 0d2ad849da09bdd44b3339d136e53dc67a58a5c0 Mon Sep 17 00:00:00 2001 From: Louis Calas Date: Wed, 9 Oct 2019 16:18:54 +0200 Subject: [PATCH] Add JUnit tests for commands --- NGCC/src/commands/Read.java | 1 + NGCC/tests/commands/TestRead.java | 50 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 NGCC/tests/commands/TestRead.java diff --git a/NGCC/src/commands/Read.java b/NGCC/src/commands/Read.java index 44935a1..2c6e152 100644 --- a/NGCC/src/commands/Read.java +++ b/NGCC/src/commands/Read.java @@ -151,6 +151,7 @@ public class Read implements Callable { 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); diff --git a/NGCC/tests/commands/TestRead.java b/NGCC/tests/commands/TestRead.java new file mode 100644 index 0000000..77833de --- /dev/null +++ b/NGCC/tests/commands/TestRead.java @@ -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); + } + +}