#jUnit

Пользователь

от rossarko , в категории: Java , месяц назад
1 ответ последнее сообщение месяц назад от jaren

На хекслете решаю очередную задачу и застрял немного. Сначала упал один тест, потом после рефакторинга упал совершенно другой тест. Уже запутался. По заданию я должен писать методом "черный ящик" , кажется так называется, или же TDD. Тест написал, потом написал класс с инициализацией перегруженных методов. Вроде всё так, но будто что-то упустил т.к все равно не прохожу проверку.

 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
package io.hexlet;


import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static io.hexlet.implementations.Methods.fill;


import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;


class MethodsTest {
    private List<String> coll = new ArrayList<>();
    private List<String> emptyColl = new ArrayList<>();


    @BeforeEach
    public void beforeEach() {
        coll.addAll(Arrays.asList("a", "b", "c", "d"));
    }
    @Test
    public void testFill() {
        fill(coll, "*", 1, 3);
        assertEquals(Arrays.asList("a", "*", "*", "d"), coll);
    }
    @Test
    public void testFill1() {
        fill(coll, "*");
        assertEquals(Arrays.asList("*", "*", "*", "*"), coll);
    }
    @Test
    public void testFill2() {
        fill(coll, "*", 4, 6);
        assertEquals(Arrays.asList("a", "b", "c", "d"), coll);
    }
    @Test
    public void testFill3() {
        fill(coll, "*", 0, 10);
        assertEquals(Arrays.asList("*", "*", "*", "*"), coll);
    }
    @Test
    public void testFill4() {
        fill(coll, "*", 2);
        assertEquals(Arrays.asList("a", "b", "*", "*"), coll);
    }
    @Test
    public void testFill5() {
        fill(coll, "*", -1, 4);
        assertEquals(Arrays.asList("*", "*", "*", "*"), coll);
    }
    @Test
    public void testFill6() {
        fill(emptyColl, "*");
        assertEquals(Arrays.asList(), emptyColl);
    }
    @Test
    public void testFill7() {
        fill(coll, "*", 5, 6);
        assertEquals(Arrays.asList("a", "b", "c", "d"), coll);
    }
}



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Failures (1):
  JUnit Jupiter:TestsTest:testRightImplementation()
    MethodSource [className = 'io.hexlet.TestsTest', methodName = 'testRightImplementation', methodParameterTypes = '']
    => org.opentest4j.AssertionFailedError: [The tests should have passed, but they failed] 
Expecting value to be true but was false
       java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
       java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
       io.hexlet.TestsTest.testRightImplementation(TestsTest.java:44)
       java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
       java.base/java.lang.reflect.Method.invoke(Method.java:580)
       org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
       org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
       org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
       org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
       org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
       [...]