Skip to content

Commit 793ae80

Browse files
committed
added Xunit
1 parent 5b022cc commit 793ae80

25 files changed

+800
-0
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
os:
5+
- linux
6+
env:
7+
- SOURCE_DIR_1=006-Xunit
8+
script:
9+
- cd $SOURCE_DIR_1 && gradle check
10+

006-Xunit/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version '1.0-SNAPSHOT'
2+
3+
apply plugin: 'java'
4+
5+
sourceCompatibility = 1.8
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
testCompile group: 'junit', name: 'junit', version: '4.12'
13+
compile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
14+
compile 'com.intellij:annotations:+@jar'
15+
compile group: 'com.google.guava', name: 'guava', version: '19.0'
16+
}
52.9 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu May 04 15:40:26 MSK 2017
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

006-Xunit/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

006-Xunit/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

006-Xunit/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = '006-junit'
2+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package task.Tester;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
import org.jetbrains.annotations.Nullable;
5+
6+
import java.io.PrintStream;
7+
import java.lang.reflect.Method;
8+
9+
public class TestResult {
10+
public final @NotNull Method method;
11+
public final boolean ok;
12+
public final @NotNull String message;
13+
public final @Nullable Throwable exception;
14+
public final long time;
15+
16+
private TestResult(@NotNull Method method, boolean ok, @NotNull String message, @Nullable Throwable exception, long time) {
17+
this.method = method;
18+
this.ok = ok;
19+
this.message = message;
20+
this.exception = exception;
21+
this.time = time;
22+
}
23+
24+
public static TestResult ok(@NotNull Method method, long time) {
25+
return new TestResult(method, true, "ok.", null, time);
26+
}
27+
28+
public static TestResult expectedException(@NotNull Method method, @NotNull Class<? extends Throwable> exceptionClass, long time) {
29+
return new TestResult(method, false, "expected " + exceptionClass.getName(), null, time);
30+
}
31+
32+
public static TestResult exception(@NotNull Method method, @NotNull Throwable exception, long time) {
33+
return new TestResult(method, false, "exception: ", exception, time);
34+
}
35+
36+
public static TestResult ignored(@NotNull Method method, @NotNull String message) {
37+
return new TestResult(method, true, "ignore. \ncause:" + message, null, 0);
38+
}
39+
40+
public void print(PrintStream out) {
41+
out.println(method);
42+
if (ok) {
43+
out.println("Ok");
44+
out.println(message);
45+
} else {
46+
out.println("Fail");
47+
out.println(message);
48+
if (exception != null) {
49+
exception.printStackTrace(out);
50+
}
51+
}
52+
out.println("time: "+ time + "ms");
53+
out.println();
54+
out.println();
55+
}
56+
}

0 commit comments

Comments
 (0)