q2 et q4( à faire test et mutation)
This commit is contained in:
@@ -14,4 +14,45 @@ Discuss the test smell you found with the help of PMD and propose here an improv
|
||||
Include the improved test code in this file.
|
||||
|
||||
## Answer
|
||||
On lance la commande
|
||||
`pmd check -d ./test_folder/commons-math/ -R category/java/errorprone.xml/DetachedTestCase -r results_q2_tp3.txt -f text`
|
||||
|
||||
---
|
||||
`
|
||||
./test_folder/commons-math/commons-math-legacy-core/src/test/java/org/apache/commons/math4/legacy/core/MathArraysTest.java:730: DetachedTestCase: Probable detached JUnit test case.
|
||||
./test_folder/commons-math/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java:169: DetachedTestCase: Probable detached JUnit test case.
|
||||
./test_folder/commons-math/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/linear/SingularValueDecompositionTest.java:202: DetachedTestCase: Probable detached JUnit test case.
|
||||
./test_folder/commons-math/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/stat/regression/MillerUpdatingRegressionTest.java:559: DetachedTestCase: Probable detached JUnit test case.
|
||||
`
|
||||
---
|
||||
On a pris le 1ere erreur:
|
||||
```
|
||||
public void testConcatenateEmptyArguments() {
|
||||
final double[] x = new double[] {0, 1, 2};
|
||||
final double[] y = new double[] {3};
|
||||
final double[] z = new double[] {};
|
||||
final double[] u = new double[] {0, 1, 2, 3};
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(x, z, y), 0);
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(x, y, z), 0);
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(z, x, y), 0);
|
||||
Assert.assertEquals(0, MathArrays.concatenate(z, z, z).length);
|
||||
}
|
||||
```
|
||||
|
||||
On peut voir quand il n'a pas l'annotation `@Test` au début de class test donc normalement le test
|
||||
qu'il a fait mais JUnit n'execute pas.
|
||||
|
||||
Voici la correction:
|
||||
```
|
||||
@Test
|
||||
public void testConcatenateEmptyArguments() {
|
||||
final double[] x = new double[] {0, 1, 2};
|
||||
final double[] y = new double[] {3};
|
||||
final double[] z = new double[] {};
|
||||
final double[] u = new double[] {0, 1, 2, 3};
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(x, z, y), 0);
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(x, y, z), 0);
|
||||
Assert.assertArrayEquals(u, MathArrays.concatenate(z, x, y), 0);
|
||||
Assert.assertEquals(0, MathArrays.concatenate(z, z, z).length);
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user