mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Java: Add inline test expectations for MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.qlref
This commit is contained in:
@@ -1 +1,2 @@
|
||||
Likely Bugs/Frameworks/JUnit/MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.ql
|
||||
query: Likely Bugs/Frameworks/JUnit/MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TestORM {
|
||||
* Test of form `when(mockedObject.methodToBeMocked()).thenReturn(someVal)`.
|
||||
*/
|
||||
@Test
|
||||
public void nonCompliant1() {
|
||||
public void nonCompliant1() { // $ Alert
|
||||
Employee sampleEmployee = new Employee("John Doe");
|
||||
EmployeeRecord employeeRecordMock = mock(EmployeeRecord.class); // NON_COMPLIANT: All public methods of the mocked object are used
|
||||
when(employeeRecordMock.add(sampleEmployee)).thenReturn(0); // Mocked EmployeeRecord.add
|
||||
@@ -44,7 +44,7 @@ public class TestORM {
|
||||
* Test of form `doReturn(someVal).when(mockedObject).methodToBeMocked()`.
|
||||
*/
|
||||
@Test
|
||||
public void nonCompliant2() {
|
||||
public void nonCompliant2() { // $ Alert
|
||||
Employee sampleEmployee = new Employee("John Doe");
|
||||
EmployeeRecord employeeRecordMock = mock(EmployeeRecord.class); // NON_COMPLIANT: All public methods of the mocked object are used
|
||||
doReturn(0).when(employeeRecordMock).add(sampleEmployee); // Mocked EmployeeRecord.add
|
||||
|
||||
Reference in New Issue
Block a user