forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test case validating LambdaTest works
See com-lihaoyi#553
- Loading branch information
Showing
2 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
contrib/testng/test/resources/demo/test/src/lambdatest/SimpleLambdaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package lambdatest; | ||
|
||
import static de.tobiasroeser.lambdatest.Expect.*; | ||
|
||
import org.testng.annotations.*; | ||
import de.tobiasroeser.lambdatest.testng.FreeSpec; | ||
|
||
|
||
/** | ||
* Test case taken from https://github.com/lefou/LambdaTest#writing-tests-with-lambda-test | ||
*/ | ||
public class SimpleLambdaTest extends FreeSpec { | ||
public SimpleLambdaTest() { | ||
|
||
test("1 + 1 = 2", () -> { | ||
expectEquals(1 + 1, 2); | ||
}); | ||
|
||
test("a pending test", () -> pending()); | ||
|
||
test("divide by zero", () -> { | ||
int a = 2; | ||
int b = 0; | ||
intercept(ArithmeticException.class, () -> { | ||
int c = a / b; | ||
}); | ||
}); | ||
|
||
section("A String should", () -> { | ||
final String aString = "A string"; | ||
|
||
test("match certain criteria", () -> { | ||
expectString(aString) | ||
.contains("string") | ||
.containsIgnoreCase("String") | ||
.startsWith("A") | ||
.endsWith("ng") | ||
.hasLength(8); | ||
}); | ||
|
||
test("be not longer than 2", () -> { | ||
expectString(aString).isLongerThan(2); | ||
}); | ||
}); | ||
|
||
test("demo of a fail", () -> { | ||
"yes".equals("yes and no"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters