Bonjour,
J'ai créé une "test suite" de JUnit pour examiner une méthode de multiplication d'une classe car j'ai commencé à apprendre JUnit.
Le problème est que, au moment où je veux démarrer le test unitaire, il me donne une faute étrange:Voici ma test suite:java.lang.Exception: no runnable methods.Je donne aussi la classe que je veux tester et la hiérarchie comme screenshot ci-dessous.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 import multiplication.*; import static org.junit.Assert.assertEquals; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({MyClass.class}) public class MyTester { @BeforeClass public static void testSetup() { } @AfterClass public static void testCleanup() { // Teardown for data used by the unit tests } @Test(expected = IllegalArgumentException.class) public void testExceptionIsThrown() { MyClass totest = new MyClass(); totest.multiply(1000, 5); } @Test public void testMultiply() { MyClass totest = new MyClass(); assertEquals("10 x 5 must be 50", 50, totest.multiply(10, 5)); } }
Merci d'avance pour vos idées / solutions.
Partager