Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/codacy/utils/NoCoverage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.codacy.utils;

public class NoCoverage {

private int magicNumber;

public NoCoverage(int magicNumber) {
this.magicNumber = magicNumber;
}

/**
* Adds 2 numbers, unless there is a magic number on the second argument
*/
public int magicAdd(int x, int y) {
if (y == magicNumber) {
System.out.println("hey2");
return y - x;
} else {
return x + y;
}
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/codacy/utils/aMath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.codacy.utils;

public class aMath {

Check notice on line 3 in src/main/java/com/codacy/utils/aMath.java

View check run for this annotation

Codacy Development / Codacy Static Code Analysis

src/main/java/com/codacy/utils/aMath.java#L3

The class name 'aMath' doesn't match '[A-Z][a-zA-Z0-9]*'

private int magicNumber;

public aMath(int magicNumber) {
this.magicNumber = magicNumber;
}

/**
* Adds 2 numbers, unless there is a magic number on the second argument
*/
public int magicAdd(int x, int y) {
if (y == magicNumber) {
System.out.println("hey2");
return y - x;
} else {
return x + y;
}
}
}
21 changes: 21 additions & 0 deletions src/test/java/com/codacy/utils/aMathTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.codacy.utils;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class aMathTest {

Check notice on line 7 in src/test/java/com/codacy/utils/aMathTest.java

View check run for this annotation

Codacy Development / Codacy Static Code Analysis

src/test/java/com/codacy/utils/aMathTest.java#L7

The class name 'aMathTest' doesn't match '^Test.*$|^[A-Z][a-zA-Z0-9]*Test(s|Case)?$'
@Test
public void shouldAddNumbers() {
aMath math = new aMath(23);

assertEquals(7, math.magicAdd(3, 4));
}

// Uncomment this to have 100% coverage
@Test
public void shouldSubtractIfMagicNumber() {
Math math = new Math(4);
assertEquals(1, math.magicAdd(3, 4));
}
}