Skip to content

Commit 568b4a3

Browse files
committed
Quickstart docs
1 parent f0c9730 commit 568b4a3

File tree

7 files changed

+102
-7
lines changed

7 files changed

+102
-7
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616

1717
Hungry for some good diffs? Check out the [documentation](https://jatcwang.github.io/difflicious/)!
1818

19-
# Attributions & Inspirations
19+
# Contributing
20+
21+
All contributions are welcome including suggestions and ideas. For larger changes please raise an issue
22+
first to avoid duplicate work :)
23+
24+
# Attributions
2025

2126
This project takes many inspirations from
2227

docs/docs/docs/TestFrameworkIntegrations.md docs/docs/docs/LibraryIntegrations.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
layout: docs
3-
title: "Test Framework Integrations"
4-
permalink: docs/test-framework-integrations
3+
title: "Library Integrations"
4+
permalink: docs/library-integrations
55
---
66

7-
# Test Framework Integrations
7+
# Library Integrations
88

99
## MUnit
1010

@@ -47,3 +47,22 @@ class MyTest extends AnyFunSuite {
4747
}
4848
}
4949
```
50+
51+
## Cats
52+
53+
Differ instances for cats data structures like `NonEmptyList` and `Chain` can be found in
54+
55+
```
56+
"com.github.jatcwang" %% "difflicious-scalatest" % "{{ site.version }}" % Test
57+
```
58+
59+
```scala mdoc:nest
60+
import difflicious.Differ
61+
import difflicious.cats.implicits._
62+
import cats.data.{NonEmptyMap, NonEmptyList}
63+
64+
val differ: Differ[List[NonEmptyMap[String, NonEmptyList[Int]]]] = Differ[List[NonEmptyMap[String, NonEmptyList[Int]]]]
65+
```
66+
67+
68+

docs/docs/docs/QuickStart.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout: docs
3+
title: "Quickstart"
4+
permalink: docs/quickstart
5+
---
6+
7+
# Quickstart
8+
9+
Let's see how you can use Difflicious in your MUnit tests
10+
11+
First, add the following dependency in your SBT configuration:
12+
13+
```
14+
"com.github.jatcwang" %% "difflicious-munit" % "{{ site.version }}" % Test
15+
```
16+
17+
If you are running tests using **IntelliJ IDEA**'s test runner, you will want
18+
to turn off the red text coloring it uses for test failure outputs because
19+
it interferes with difflicious' color outputs.
20+
21+
In <b>File | Settings | Editor | Color Scheme | Console Colors | Console | Error Output</b>, uncheck the red foreground color.
22+
23+
Let's say you have some case classes..
24+
25+
```scala mdoc:silent
26+
case class Person(
27+
name: String,
28+
age: Int,
29+
occupation: String
30+
)
31+
```
32+
33+
To perform diffs with Difflicious, you will need to derive some `Differs`
34+
35+
```scala mdoc:silent
36+
import munit.FunSuite
37+
import difflicious.Differ
38+
import difflicious.munit.MUnitDiff._
39+
40+
class ExampleTest extends FunSuite {
41+
42+
// Derive Differs for case class and sealed traits
43+
implicit val personDiffer: Differ[Person] = Differ.derive[Person]
44+
45+
test("two list of people should be the same") {
46+
Differ[List[Person]].assertNoDiff(
47+
List(
48+
Person("Alice", 50, "Doctor")
49+
),
50+
List(
51+
Person("Alice", 40, "Doctor"),
52+
Person("Bob", 30, "Teacher")
53+
)
54+
)
55+
}
56+
}
57+
```
58+
59+
Run the tests, and you should see a nice failure diff:
60+
61+
<img src="../img/diff_failure.jpg" />
62+
63+
Pretty right? You should explore the next sections of the documentation and learn about the different Differs
64+
and how you can configure them!

docs/src/main/resources/microsite/data/menu.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
options:
22
- title: Introduction
33
url: docs/introduction
4+
- title: Quickstart
5+
url: docs/quickstart
46
- title: Types of Differs
57
url: docs/types-of-differs
68
- title: Configuring Differs
79
url: docs/configuring-differs
8-
- title: Test Framework Integrations
9-
url: docs/test-framework-integrations
10+
- title: Library Integrations
11+
url: docs/library-integrations
1012
- title: Best Practices / FAQ
1113
url: docs/best-practices-and-faq
1214
- title: Cheatsheet
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package difflicious.cats
2+
3+
object implicits extends CatsInstances

modules/cats/src/test/scala/CatsDataDiffSpec.scala modules/cats/src/test/scala/difflicious/cats/CatsDataDiffSpec.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
package difflicious.cats
2+
13
import munit.FunSuite
2-
import difflicious.cats.CatsInstances._
34
import cats.data._
45
import cats.laws.discipline.arbitrary._
56
import difflicious.Differ
67
import difflicious.testtypes.{CC, MapKey}
78
import difflicious.testutils._
89
import difflicious.implicits._
10+
import difflicious.cats.implicits._
911

1012
class CatsDataDiffSpec extends FunSuite {
1113
test("NonEmptyMap: Has map-like diff result") {

0 commit comments

Comments
 (0)