-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpaghettiCodeDetectorTest.java
More file actions
71 lines (60 loc) · 3.05 KB
/
SpaghettiCodeDetectorTest.java
File metadata and controls
71 lines (60 loc) · 3.05 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.antipattern.detector.AntipatternDetector;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import com.antipattern.detector.AntipatternDetector.*;
/**
This class tests the functionality of the SpaghettiCodeDetector class.
It verifies whether the getDefaultTokens and getRequiredTokens methods
return the correct values, and whether the visitToken method is properly
implemented.
*/
class SpaghettiCodeDetectorTest {
/**
* This test method checks whether the getDefaultTokens method of the
* SpaghettiCodeDetector returns the expected integer array.
* It creates a ConcreteSpaghettiCodeDetector object, retrieves the default
* tokens array from it, and compares it to the expected array.
* This is a white box testing technique.
*/
/**
* The method getDefaultTokens() and getRequiredTokens() are white box testing techniques because the tests
* are directly accessing the implementation details of the SpaghettiCodeDetector class by creating an instance of ConcreteSpaghettiCodeDetector and then invoking the getDefaultTokens() and getRequiredTokens() methods. This allows the tests to verify if the methods return the expected output based on the internal implementation of the ConcreteSpaghettiCodeDetector.
* Hence, these methods are white box testing techniques.
*/
@Test
void getDefaultTokens() {
SpaghettiCodeDetector detector = new ConcreteSpaghettiCodeDetector();
assertNotNull(detector.getDefaultTokens());
assertArrayEquals(new int[]{TokenTypes.METHOD_DEF}, detector.getDefaultTokens());
}
/**
* This test method checks whether the getRequiredTokens method of the
* SpaghettiCodeDetector returns the expected integer array.
* It creates a ConcreteSpaghettiCodeDetector object, retrieves the required
* tokens array from it, and compares it to the expected array.
* This is a white box testing technique.
*/
@Test
void getRequiredTokens() {
SpaghettiCodeDetector detector = new ConcreteSpaghettiCodeDetector();
assertNotNull(detector.getRequiredTokens());
assertArrayEquals(detector.getDefaultTokens(), detector.getRequiredTokens());
}
/**
* This test method checks whether the getRequiredTokens method of the
* SpaghettiCodeDetector returns the expected integer array.
* It creates a ConcreteSpaghettiCodeDetector object, retrieves the required
* tokens array from it, and compares it to the expected array.
* This is a white box testing technique.
*/
@Test
void visitToken() {
// TODO: write test case for visitToken method
ConcreteSpaghettiCodeDetector detector = new ConcreteSpaghettiCodeDetector();
int[] expectedTokens = {1, 2, 3, 4, 5};
assertTrue(true);
}
}