munit-snapshot_2.13

Snapshot testing for MUnit

License

License

MIT
GroupId

GroupId

com.github.lolgab
ArtifactId

ArtifactId

munit-snapshot_2.13
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

munit-snapshot_2.13
Snapshot testing for MUnit
Project URL

Project URL

https://github.com/lolgab/munit-snapshot

Download munit-snapshot_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.lolgab/munit-snapshot_2.13/ -->
<dependency>
    <groupId>com.github.lolgab</groupId>
    <artifactId>munit-snapshot_2.13</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.lolgab/munit-snapshot_2.13/
implementation 'com.github.lolgab:munit-snapshot_2.13:0.0.4'
// https://jarcasting.com/artifacts/com.github.lolgab/munit-snapshot_2.13/
implementation ("com.github.lolgab:munit-snapshot_2.13:0.0.4")
'com.github.lolgab:munit-snapshot_2.13:jar:0.0.4'
<dependency org="com.github.lolgab" name="munit-snapshot_2.13" rev="0.0.4">
  <artifact name="munit-snapshot_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.lolgab', module='munit-snapshot_2.13', version='0.0.4')
)
libraryDependencies += "com.github.lolgab" % "munit-snapshot_2.13" % "0.0.4"
[com.github.lolgab/munit-snapshot_2.13 "0.0.4"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scalameta : munit_2.13 jar 0.7.21
com.lihaoyi : upickle_2.13 jar 1.2.3
com.lihaoyi : os-lib_2.13 jar 0.7.2

Project Modules

There are no modules declared in this project.

munit-snapshot

Snapshot testing for MUnit. This project is a basic implementation of the snapshot tests.

Getting started

After adding the munit-snapshot dependency:

libraryDependencies += "com.github.lolgab" %% "munit-snapshot" % "0.0.4" % Test

You can create a basic test in a file called ExampleSnapshotTest.scala:

package example

import munit.snapshot._
import upickle.default._

class ExampleSnapshotTest extends SnapshotSuite {
  snapshotTest("one plus one") {
    1 + 1
  }
}

Running the tests the first time will generate a file called ExampleSnapshotTest.json with the following content:

{
  "one plus one": 2
}

where "one plus one" is the test name (it should be unique in the file) and 2 is the result of the test evaluation.

The subsequent runs will evaluate the expression again, and fail when they do not match the saved json file.

If a test is removed, running the tests will remove the key from the json file.

Here you can see what happens if I change the json file to:

{
  "one plus one": 3
}

Running the test again will output:

6:class ExampleSnapshotTest extends SnapshotSuite {
7:  snapshotTest("one plus one") {
8:    1 + 1
values are not the same
=> Obtained
2
=> Diff (- obtained, + expected)
-2
+3

Versions

Version
0.0.4
0.0.3
0.0.2
0.0.1