Skip to content

Commit b5a325d

Browse files
committed
Added example test
1 parent 9c19211 commit b5a325d

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before_install:
55
- chmod +x gradlew
66

77
script:
8-
- ./gradlew clean build -x test
8+
- ./gradlew clean build
99

1010
notifications:
1111
email: false

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ buildscript {
1515
apply plugin: 'java'
1616
apply plugin: 'kotlin'
1717

18+
apply from: 'testformatter.gradle'
19+
1820
sourceCompatibility = 1.8
1921

2022
repositories {

src/main/kotlin/co/zsmb/verbalexpressions/VerEx.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ class VerEx {
1919
}
2020

2121
private val pattern: Pattern
22-
get() {
23-
val compile = Pattern.compile("$prefixes$source$suffixes", modifiers)
24-
println(compile)
25-
return compile
26-
}
22+
get() = Pattern.compile("$prefixes$source$suffixes", modifiers)
2723

2824
private var prefixes = StringBuilder()
2925
private var source = StringBuilder()
@@ -145,5 +141,4 @@ class VerEx {
145141
return this
146142
}
147143

148-
149144
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package co.zsmb.verbalexpressions
2+
3+
import org.junit.Assert.assertTrue
4+
import org.junit.Test
5+
6+
class ExampleTest {
7+
8+
@Test
9+
fun testUrls() {
10+
val verex = VerEx()
11+
.startOfLine()
12+
.then("http")
13+
.maybe("s")
14+
.then("://")
15+
.maybe("www")
16+
.anythingBut(" ")
17+
.endOfLine()
18+
19+
assertTrue("https://www.google.com" matches verex)
20+
assertTrue("http://zsmb.co" matches verex)
21+
assertTrue("https://www.wikipedia.org/" matches verex)
22+
}
23+
24+
}

testformatter.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
tasks.withType(Test) {
2+
testLogging {
3+
// set options for log level LIFECYCLE
4+
events "passed", "skipped", "failed", "standardOut"
5+
showExceptions true
6+
exceptionFormat "full"
7+
showCauses true
8+
showStackTraces true
9+
10+
// set options for log level DEBUG and INFO
11+
debug {
12+
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
13+
exceptionFormat "full"
14+
}
15+
info.events = debug.events
16+
info.exceptionFormat = debug.exceptionFormat
17+
18+
afterSuite { desc, result ->
19+
if (!desc.parent) { // will match the outermost suite
20+
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
21+
def startItem = '| ', endItem = ' |'
22+
def repeatLength = startItem.length() + output.length() + endItem.length()
23+
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)