Skip to content

Locke/sbt-scalatest-coreasm

Repository files navigation

build status

ScalatestCoreASMPlugin

About

This SBT Plugin automatically generates ScalaTest files from CoreASM specifications.

Usage

This project isn't published yet! Currently you need to download, compile and install this repository on your own machine..

Add addSbtPlugin("de.athalis" % "sbt-scalatest-coreasm" % "0.1.0-SNAPSHOT") to project/plugins.sbt to have this plugin available in sbt.

This plugin needs to be enabled on a desired project via .enablePlugins(ScalatestCoreASMPlugin), usually in build.sbt. In a multi-project build that might look like this:

lazy val yourSubProject = (project in file("yourSubProject"))
  .enablePlugins(ScalatestCoreASMPlugin)
  .settings(
    // ...
  )

Create a folder named coreasm in the test folder of your project. In a multi-project build that would be yourSubProject/src/test/coreasm.

Place your CoreASM test files either directly in that folder, or create sub folders to group multiple test files together.

The ScalaTest source files are generated by the task test-coreasm:generateCoreASMTests, for example sbt:root> yourSubProject/test-coreasm:generateCoreASMTests.

This task is registered as sourceGenerator in the test build and therefore automatically called when tests are compiled. This means that you can just call the test:compile task, for example sbt:root> yourSubProject/test:compile.

Usually you could just execute the test task in sbt to a) generate the ScalaTest files b) compile them and c) execute them, for example it's sufficient to just execute sbt:root> yourSubProject/test.

Settings

This Plugin uses customizable scoped settings:

  • sourceDirectory in TestCoreASM sets the directory in which the CoreASM files are searched. Default: src/coreasm
  • sourceManaged in TestCoreASM sets the directory where the generated ScalaTest files are stored. Default: target/src_managed/test/coreasm
  • includeFilter in TestCoreASM sets which files are considered as CoreASM file. Default: ("*.casm" || "*.coreasm")
  • excludeFilter in TestCoreASM sets which files to ignore when searching for CoreASM files. Default: HiddenFileFilter
  • testCoreASMPackageName in TestCoreASM sets the package name for the generated scalatest classes. Default: de.athalis.sbt.testcoreasm.generated

Note: this plugin sets fork in Test := true in your test scope, as the CoreASM Engine writes to System.out, which needs to be redirected in order to check the outputs of the execution.

Examples

See the folder sbt-test. It contains projects which are used for continuous testing.

The project diningPhilosophers demonstrates that this plugin can be used in projects using scala 2.10, 2.11 and 2.12.

The project customSettings demonstrates how to overwrite the settings of this plugin.

How to write CoreASM test specifications

(Note: this section should be part of the CoreASM documentation)

A CoreASM test specification is a CoreASM specification annotated with required and refused outputs. They are written in comments and valid for the whole file

Additionally maxsteps can be set to limit the execution steps.

Example of a basic CoreASM test specification:

CoreASM FooTest

use Standard

// @require "AAAA"
// @refuse "BBBB"
// @maxsteps 2

init Foo

rule Foo = {
  choose x in BOOLEAN do {
    if (x = true) then {
      print "AAAA"
    }
    else {
      print "BBBB"
    }
  }
}

TODO

See TODO.

About

generate scalatest classes for CoreASM specifications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published