<commit_before>= Lambda Test
:toc:
:toc-placement: preamble
:lambdatestversion: 0.7.1
:documentationversion: 0.7.1
:testngversion: 6.11
:junitversion: 4.12
:lambdatest: LambdaTest
ifndef::env-asciidoclet[:srcdir: src/main/java/]
ifdef::env-asciidoclet[:srcdir:]
ifndef::env-asciidoclet[:javasuffix: .java]
ifdef::env-asciidoclet[:javasuffix: .html]

ifdef::env-github[]
image:https://github.com/lefou/LambdaTest/workflows/.github/workflows/build.yml/badge.svg["Build Status", link="https://github.com/lefou/LambdaTest/actions"]
image:https://api.codacy.com/project/badge/Grade/e886bd7ca9784ecfb00fe8afb59b8909["Codacy code quality", link="https://www.codacy.com/app/lefou/LambdaTest"]
image:https://javadoc.io/badge2/de.tototec/de.tobiasroeser.lambdatest/javadoc.svg["JavaDoc", link="https://javadoc.io/doc/de.tototec/de.tobiasroeser.lambdatest"]
image:https://badges.gitter.im/lefou/LambdaTest.svg["Chat on Gitter", link="https://gitter.im/lefou/LambdaTest"]
endif::[]

ifndef::env-github[Project Homepage: https://github.com/lefou/LambdaTest]


Lambda-enabled functional testing on top of JUnit and TestNG.

Documentation for LambdaTest {documentationversion}.


== Motivation

When constrained to work in a Java-only toolchain, I really miss http://scalatest.org[ScalaTest].
I tried some lambda enabled test frameworks, but until now (2014), did not find a suitable solution without compromizing the integration benefits.

Thus I decided to write a small and generic test library that allows writing of functional test without reinventing the wheel.
LambdaTest works on top of JUnit and TestNG, all you need is to add it to the test classpath.
No further adaptions to your existing test setup are needed.
You will immediately gain the joy of Lambda-enabled functional testing, better assertion messages and nicely colored output.

== Features

Most important features are:

* Write test via API (No longer required to have each test in a separate annotated method)
* Meaningful names for tests
* Nicely colored output per test case
* Easy to write data-centric tests (e.g. generate as much test cases as you need programmatically, e.g. in a loop)
* Easy to intercept exceptions with `intercept`
* Useful assertion message and difference highlighting in `expectXXX`-methods
* Opt-in to not fail fast when using `expectXXX`-methods (see more than the first assertion error)
* Easy to mark pending tests
* Contains useful tools to work with temporary files and directories
* Easy way to create proxies as mock dependencies

== Documentation

Beside this document, you can also read the https://javadoc.io/doc/de.tototec/de.tototec.utils.functional[JavadDoc for LambdaTest]

== Download from Maven Central

{lambdatest} is available from http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22de.tototec%22%20AND%20a%3A%22de.tobiasroeser.lambdatest%22[Maven central repository].

Maven users can use the following dependency declaration:

[source,xml,subs="attributes,verbatim"]
----
<dependencies>
  <dependency>
    <groupId>de.tototec</groupId>
    <artifactId>de.tobiasroeser.lambdatest</artifactId>
    <version>{lambdatestversion}</version>
    <scope>test</scope>
  </dependency>
  <!-- If you use LambdaTest with JUnit -->
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>{junitversion}</version>
    <scope>test</scope>
  </dependency>
  <!-- If you use LambdaTest with TestNG -->
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>{testngversion}</version>
    <scope>test</scope>
  </dependency>
</dependencies>
----

http://sbuild.org[SBuild] users can use the following dependencies:

.Use with JUnit
[source,scala,subs="attributes"]
----
"mvn:de.tototec:de.tobiasroeser.lambdatest:{lambdatestversion}" ~
  "mvn:junit:junit:{junitversion}"
----

.Use with TestNG
[source,scala,subs="attributes"]
----
"mvn:de.tototec:de.tobiasroeser.lambdatest:{lambdatestversion}" ~
  "mvn:org.testng:testng:{testngversion}"
----

[NOTE]
--
If you use LambdaTest with `mill.testng.TestNGFramework` (in Mill or sbt), you may see extra verbose output.
You can disable the progress output of `mill.testng.TestNGFramework` by setting the `mill.testng.printProgress` property to `0`.

.`build.sc`: Make `mill.testng.TestNGFramework` runner less verbose in Mill
[source,scala,subs="attributes"]
----
object test extends TestModule.TestNg {
  override def forkArgs = T{ super.forkArgs() ++ Seq("-Dmill.testng.printProgress=0") }
}
----
--

== Choose your favorite Unit-Test Runner: JUnit or TestNG

With {lambdatest}, you need to only know LambdaTests very simple and minimalistic API but can use it to write test for JUnit and TestNG.

To avoid a dependency to both frameworks at the same time, your test class  inherits a different base class, but besides that, everything else is the same.

For JUnit you inherit link:{srcdir}de/tobiasroeser/lambdatest/junit/FreeSpec{javasuffix}[`de.tobiasroeser.lambdatest.junit.FreeSpec`].

For TestNG you inherit
link:{srcdir}de/tobiasroeser/lambdatest/testng/FreeSpec{javasuffix}[`de.tobiasroeser.lambdatest.testng.FreeSpec`].<commit_msg>Moved into other section (#44)<commit_after>= Lambda Test
:toc:
:toc-placement: preamble
:lambdatestversion: 0.7.1
:documentationversion: 0.7.1
:testngversion: 6.11
:junitversion: 4.12
:lambdatest: LambdaTest
ifndef::env-asciidoclet[:srcdir: src/main/java/]
ifdef::env-asciidoclet[:srcdir:]
ifndef::env-asciidoclet[:javasuffix: .java]
ifdef::env-asciidoclet[:javasuffix: .html]

ifdef::env-github[]
image:https://github.com/lefou/LambdaTest/workflows/.github/workflows/build.yml/badge.svg["Build Status", link="https://github.com/lefou/LambdaTest/actions"]
image:https://api.codacy.com/project/badge/Grade/e886bd7ca9784ecfb00fe8afb59b8909["Codacy code quality", link="https://www.codacy.com/app/lefou/LambdaTest"]
image:https://javadoc.io/badge2/de.tototec/de.tobiasroeser.lambdatest/javadoc.svg["JavaDoc", link="https://javadoc.io/doc/de.tototec/de.tobiasroeser.lambdatest"]
image:https://badges.gitter.im/lefou/LambdaTest.svg["Chat on Gitter", link="https://gitter.im/lefou/LambdaTest"]
endif::[]

ifndef::env-github[Project Homepage: https://github.com/lefou/LambdaTest]


Lambda-enabled functional testing on top of JUnit and TestNG.

Documentation for LambdaTest {documentationversion}.


== Motivation

When constrained to work in a Java-only toolchain, I really miss http://scalatest.org[ScalaTest].
I tried some lambda enabled test frameworks, but until now (2014), did not find a suitable solution without compromizing the integration benefits.

Thus I decided to write a small and generic test library that allows writing of functional test without reinventing the wheel.
LambdaTest works on top of JUnit and TestNG, all you need is to add it to the test classpath.
No further adaptions to your existing test setup are needed.
You will immediately gain the joy of Lambda-enabled functional testing, better assertion messages and nicely colored output.

== Features

Most important features are:

* Write test via API (No longer required to have each test in a separate annotated method)
* Meaningful names for tests
* Nicely colored output per test case
* Easy to write data-centric tests (e.g. generate as much test cases as you need programmatically, e.g. in a loop)
* Easy to intercept exceptions with `intercept`
* Useful assertion message and difference highlighting in `expectXXX`-methods
* Opt-in to not fail fast when using `expectXXX`-methods (see more than the first assertion error)
* Easy to mark pending tests
* Contains useful tools to work with temporary files and directories
* Easy way to create proxies as mock dependencies

== Documentation

Beside this document, you can also read the https://javadoc.io/doc/de.tototec/de.tototec.utils.functional[JavadDoc for LambdaTest]

== Download from Maven Central

{lambdatest} is available from http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22de.tototec%22%20AND%20a%3A%22de.tobiasroeser.lambdatest%22[Maven central repository].

Maven users can use the following dependency declaration:

[source,xml,subs="attributes,verbatim"]
----
<dependencies>
  <dependency>
    <groupId>de.tototec</groupId>
    <artifactId>de.tobiasroeser.lambdatest</artifactId>
    <version>{lambdatestversion}</version>
    <scope>test</scope>
  </dependency>
  <!-- If you use LambdaTest with JUnit -->
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>{junitversion}</version>
    <scope>test</scope>
  </dependency>
  <!-- If you use LambdaTest with TestNG -->
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>{testngversion}</version>
    <scope>test</scope>
  </dependency>
</dependencies>
----

http://sbuild.org[SBuild] users can use the following dependencies:

.Use with JUnit
[source,scala,subs="attributes"]
----
"mvn:de.tototec:de.tobiasroeser.lambdatest:{lambdatestversion}" ~
  "mvn:junit:junit:{junitversion}"
----

.Use with TestNG
[source,scala,subs="attributes"]
----
"mvn:de.tototec:de.tobiasroeser.lambdatest:{lambdatestversion}" ~
  "mvn:org.testng:testng:{testngversion}"
----

== Choose your favorite Unit-Test Runner: JUnit or TestNG

With {lambdatest}, you need to only know LambdaTests very simple and minimalistic API but can use it to write test for JUnit and TestNG.

To avoid a dependency to both frameworks at the same time, your test class  inherits a different base class, but besides that, everything else is the same.

For JUnit you inherit link:{srcdir}de/tobiasroeser/lambdatest/junit/FreeSpec{javasuffix}[`de.tobiasroeser.lambdatest.junit.FreeSpec`].

For TestNG you inherit
link:{srcdir}de/tobiasroeser/lambdatest/testng/FreeSpec{javasuffix}[`de.tobiasroeser.lambdatest.testng.FreeSpec`].


[NOTE]
--
If you use LambdaTest with `mill.testng.TestNGFramework` (in Mill or sbt), you may see extra verbose output.
You can disable the progress output of `mill.testng.TestNGFramework` by setting the `mill.testng.printProgress` property to `0`.

.`build.sc`: Make `mill.testng.TestNGFramework` runner less verbose in Mill
[source,scala,subs="attributes"]
----
object test extends TestModule.TestNg {
  override def forkArgs = T{ super.forkArgs() ++ Seq("-Dmill.testng.printProgress=0") }
}
----
--
{'fraction_non_alphanumeric': 0.11805152043385629, 'fraction_numerical': 0.010652721286073988, 'mean_word_length': 5.132422802850356, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 71, 'https://': 20, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5231276', 'n_tokens_mistral': 3461, 'n_tokens_neox': 3304, 'n_words': 925}