79248024

Date: 2024-12-03 14:40:13
Score: 2.5
Natty:
Report link

@makasprzak answer is right but I want to add that if you want to make your tests work with TestNG without changing the variable to non-final then you can do the following:

package inject_mocks_test;

import org.mockito.Mockito;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class SubjectTest {

    Section section;
    Subject subject;

    @BeforeMethod
    public void setup() {
        section = Mockito.mock(Section.class);
        subject = new Subject(section);
    }

    @Test
    public void test1() {
        assertEquals(section, subject.getSection());
    }

    @Test
    public void test2() {
        assertEquals(section, subject.getSection());        
    }
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @makasprzak
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: mbanchero