testing-plugin / arrow.meta.plugin.testing / assertThis

assertThis

fun assertThis(compilerTest: CompilerTest): Unit

Allows checking if a compiler plugin is working as expected.

It’s not necessary to write assertions with actual and expected behavior. Assertions will be built automatically from simply indicating the expected behavior in a CompilerTest.

Running the compilation from the provided configuration and getting the results (status, classes, and output messages) is possible thanks to Kotlin Compile Testing, a library developed by Thilo Schuchort.

Main schema:

assertThis(
    CompilerTest(
      config = { ... },
      code = { ... },
      assert = { ... }
    )
)

Compilation will be executed with the provided configuration (config) and code snippets (code). Then, the expected behavior (assert) will be checked.

For instance:

assertThis(
    CompilerTest(
      config = { metaDependencies },
      code = { "...".source },
      assert = {
        quoteOutputMatches("...".source) +
        "...".source.evalsTo(someValue)
      }
    )
)

Parameters

compilerTest - necessary data to run the compilation, source code to be compiled and expected behavior

See Also

CompilerTest

Do you like Arrow?

Arrow Org
<