mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-03-21 08:39:29 +01:00
initial import of project
This commit is contained in:
15
01-build-and-test/build.gradle
Normal file
15
01-build-and-test/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
||||
apply plugin: 'java'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'org.testng', name: 'testng', version: '6.+'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
|
||||
19
01-build-and-test/src/main/java/Calculator.java
Normal file
19
01-build-and-test/src/main/java/Calculator.java
Normal file
@@ -0,0 +1,19 @@
|
||||
public class Calculator {
|
||||
|
||||
/** Internal counter */
|
||||
private int counter;
|
||||
|
||||
Calculator() {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
void add(int i) {
|
||||
counter += i;
|
||||
}
|
||||
}
|
||||
|
||||
13
01-build-and-test/src/test/java/TestCalculator.java
Normal file
13
01-build-and-test/src/test/java/TestCalculator.java
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestCalculator {
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
Calculator calc = new Calculator();
|
||||
calc.add(1);
|
||||
Assert.assertEquals(calc.getCounter(), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user