I try to use junit5 for testing this method but I have some difficulties so can you make example tests with that plz.
Thank you :)
IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main.java 2050-lab3 src + Main + taxe Main Test1 - Main.java MainTest1.java \Documents\2050-lab3 A1 x7 av public static void main(String[] args) { // write your code here CodeTogether 5 Project V2050-lab3 C:\Users\ .idea > out > src Test Main Test1 2050-lab3.iml > Illi External Libraries Po Scratches and Consoles 6 System.out.println(taxe( montant: 10000, federale: true, province: false)); 7 } 8 9 10 11 o public static long taxe (long montant, boolean federale, boolean province){ double taxe = 0.00; Jif(montant > 0) { 12 13 14 15 A 16 17 18 19 if(federale ) { taxe = montant * 5/100; }else if(province) { taxe = montant * 9.975; } A 20 }else{ Run: MainTest1 1 * Favorites :. Structure 1 1 1 9 v Test Results * Main Test1 main % taxe >> Tests failed: 1, passed: 1 of 2 tests 153 ms 153 ms "C:\Program Files\Java\jdk-15\bin\java.exe" ... 153 ms 132 ms org.opentest4j.AssertionFailedError: 21 ms Expected : 10000 Actual : 10500
f = IEb 2. Terminal Build Run DE TODO e Problems O Tests failed: 1, passed: 1 (today 18:53) Event Log 12:9 2 IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main.java 2050-lab3 src Main m taxe Main Test1 - C Main.java MainTest1.java Jif(montant > 0) { \Documents\2050-lab3 12 A1 x7 av CodeTogether Project V2050-lab3 C:\Users\ .idea > out > src Test Main Test1 2050-lab3.iml > Illi External Libraries Po Scratches and Consoles if(federale ) { taxe = montant * 5/100; }else if(province){ taxe = montant * 9.975; } 13 14 15 16 17 18 19 20 21 22 23 24 }else{ throw new IllegalArgumentException("Votre montant est nul () ou ngatif"); } 25 26 27 28 29 return (long) (montant+taxe); 30 } Run: MainTest1 1 * Favorites :. Structure 1 1 1 9 v Test Results * Main Test1 main % taxe >> Tests failed: 1, passed: 1 of 2 tests 153 ms 153 ms "C:\Program Files\Java\jdk-15\bin\java.exe" ... 153 ms 132 ms org.opentest4j.AssertionFailedError: 21 ms Expected : 10000 Actual : 10500 di JL + + 2. Terminal Build Run DE TODO e Problems O Tests failed: 1, passed: 1 (today 18:53) Event Log 12:9 2 Main 01 A2 1 AV deTogether 6 IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main Test1.java 2050-lab3 Test MainTest1 mtaxe Main.java MainTest1.java v2050-lab3 C:\Users\ .Idea class MainTesti { > out > src 7 @Test V _Test 8 void main() { Main Test1 9 Long actual = 10000; 7. 2050-lab3.im 10 Long excepted = 10000; > lilli External Libraries assertEquals(actual, excepted); Po Scratches and Consoles 12 } 13 14 @Test 15 & void taxe() { 16 Long actual = 10000; 17 Long excepted = 10500; 18 assertEquals("3$", taxe (actual, true, false)); 19 //assertEquals(actual, excepted); 20 } 21 } Build: _ In ICHI : Structure Build Output 2050-lab3: build failed At 2021-02-18 01:04 with 1 error 25 sec, 709 ms C:\Users \Documents\2050-lab3\Test\MainTest1.java:18:28 MainTest1.java Test 1 error java: method taxe in class MainTesti cannot be applied to given types; method taxe in class Main Test1 cannot be applied to given types; :18 required: no arguments found: Long, boolean, boolean reason: actual and formal argument lists differ in length 6 Plugin updates available "CodeTogether", "Kite Al Code Auto Complete:... Update all Plugin Settings... Ignore these updates * Favorites E TODO e Problems 2 Terminal Build O Build completed with 1 error and O warnings in 25 sec, 709 ms (today 01:04) 1 Event Log 18:28 CRLF UTF-8 4 spaces 2 IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main.java 2050-lab3 src + Main + taxe Main Test1 - Main.java MainTest1.java \Documents\2050-lab3 A1 x7 av public static void main(String[] args) { // write your code here CodeTogether 5 Project V2050-lab3 C:\Users\ .idea > out > src Test Main Test1 2050-lab3.iml > Illi External Libraries Po Scratches and Consoles 6 System.out.println(taxe( montant: 10000, federale: true, province: false)); 7 } 8 9 10 11 o public static long taxe (long montant, boolean federale, boolean province){ double taxe = 0.00; Jif(montant > 0) { 12 13 14 15 A 16 17 18 19 if(federale ) { taxe = montant * 5/100; }else if(province) { taxe = montant * 9.975; } A 20 }else{ Run: MainTest1 1 * Favorites :. Structure 1 1 1 9 v Test Results * Main Test1 main % taxe >> Tests failed: 1, passed: 1 of 2 tests 153 ms 153 ms "C:\Program Files\Java\jdk-15\bin\java.exe" ... 153 ms 132 ms org.opentest4j.AssertionFailedError: 21 ms Expected : 10000 Actual : 10500 f = IEb 2. Terminal Build Run DE TODO e Problems O Tests failed: 1, passed: 1 (today 18:53) Event Log 12:9 2 IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main.java 2050-lab3 src Main m taxe Main Test1 - C Main.java MainTest1.java Jif(montant > 0) { \Documents\2050-lab3 12 A1 x7 av CodeTogether Project V2050-lab3 C:\Users\ .idea > out > src Test Main Test1 2050-lab3.iml > Illi External Libraries Po Scratches and Consoles if(federale ) { taxe = montant * 5/100; }else if(province){ taxe = montant * 9.975; } 13 14 15 16 17 18 19 20 21 22 23 24 }else{ throw new IllegalArgumentException("Votre montant est nul () ou ngatif"); } 25 26 27 28 29 return (long) (montant+taxe); 30 } Run: MainTest1 1 * Favorites :. Structure 1 1 1 9 v Test Results * Main Test1 main % taxe >> Tests failed: 1, passed: 1 of 2 tests 153 ms 153 ms "C:\Program Files\Java\jdk-15\bin\java.exe" ... 153 ms 132 ms org.opentest4j.AssertionFailedError: 21 ms Expected : 10000 Actual : 10500 di JL + + 2. Terminal Build Run DE TODO e Problems O Tests failed: 1, passed: 1 (today 18:53) Event Log 12:9 2 Main 01 A2 1 AV deTogether 6 IJ File Edit View Navigate Code Analyze Refactor Build Run Tools VCS Window Help 2050-lab3 - Main Test1.java 2050-lab3 Test MainTest1 mtaxe Main.java MainTest1.java v2050-lab3 C:\Users\ .Idea class MainTesti { > out > src 7 @Test V _Test 8 void main() { Main Test1 9 Long actual = 10000; 7. 2050-lab3.im 10 Long excepted = 10000; > lilli External Libraries assertEquals(actual, excepted); Po Scratches and Consoles 12 } 13 14 @Test 15 & void taxe() { 16 Long actual = 10000; 17 Long excepted = 10500; 18 assertEquals("3$", taxe (actual, true, false)); 19 //assertEquals(actual, excepted); 20 } 21 } Build: _ In ICHI : Structure Build Output 2050-lab3: build failed At 2021-02-18 01:04 with 1 error 25 sec, 709 ms C:\Users \Documents\2050-lab3\Test\MainTest1.java:18:28 MainTest1.java Test 1 error java: method taxe in class MainTesti cannot be applied to given types; method taxe in class Main Test1 cannot be applied to given types; :18 required: no arguments found: Long, boolean, boolean reason: actual and formal argument lists differ in length 6 Plugin updates available "CodeTogether", "Kite Al Code Auto Complete:... Update all Plugin Settings... Ignore these updates * Favorites E TODO e Problems 2 Terminal Build O Build completed with 1 error and O warnings in 25 sec, 709 ms (today 01:04) 1 Event Log 18:28 CRLF UTF-8 4 spaces 2