Skip to content

Commit d0c3aa8

Browse files
committed
Update readme.
1 parent 13c9e52 commit d0c3aa8

File tree

4 files changed

+56
-172
lines changed

4 files changed

+56
-172
lines changed

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 40 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,69 @@ AocKt _(short for Advent of Code - Kotlin)_ is a simple library that makes runni
1212
It is an opinionated testing framework built on [Kotest](https://kotest.io/) that defines a new `AdventSpec` specialized
1313
for testing AoC puzzle solutions with minimal boilerplate.
1414

15+
## 📑 Documentation
16+
17+
Visit the [project website](https://jadarma.github.io/advent-of-code-kotlin) for installation instructions,
18+
DSL documentation, workflow guides, advanced configuration options, and more!
19+
1520
## ✨ Features
1621

17-
- *Completely Offline* - Puzzle inputs and solutions are read from local files, no need for tokens.
18-
- *Test Driven* - Run your code from unit tests for faster feedback loops and fearless refactorings.
19-
- *DSL Driven* - Define your test cases with minimal code.
20-
- *Configurable* - You decide what runs and when using optional parameters.
21-
- *Minimal* - The test framework is the only non-Kotlin dependency.
22+
- **Completely Offline** - Puzzle inputs and solutions are read from local files, no need for tokens.
23+
- **Test-Driven** - Run your code from unit tests for faster feedback loops and fearless refactorings.
24+
- **DSL-Driven** - Define your test cases with minimal code.
25+
- **Configurable** - You decide what runs and when using optional parameters.
26+
- **Minimal** - The test framework is the only non-Kotlin dependency.
2227

2328
## ⚡ Quick Start
2429

25-
### Gradle
30+
<details open>
31+
<summary>Project Template</summary>
2632

27-
To use AocKt, simply add the dependencies and configure your project to run unit tests with Kotest:
33+
For your convenience, there is an
34+
[advent-of-code-kotlin-template](https://github.com/Jadarma/advent-of-code-kotlin-template) repository which you can
35+
use to generate your own solutions repo.
36+
It comes with a pre-configured Gradle project with all bells and whistles you might need, as well as a
37+
modified source structure for easier navigation.
38+
39+
_(If you need a working example, check out [my solutions repo](https://github.com/Jadarma/advent-of-code-kotlin-solutions).)_
40+
41+
</details>
42+
43+
<details>
44+
<summary>Standalone Gradle Project</summary>
45+
46+
To add AocKt to your existing project, simply add the dependencies and configure your unit tests to run with Kotest:
2847

2948
```kotlin
49+
plugins {
50+
kotlin("jvm") version "$kotlinVersion"
51+
}
52+
3053
repositories {
3154
mavenCentral()
3255
}
3356

3457
dependencies {
3558
implementation("io.github.jadarma.aockt:aockt-core:$aocktVersion")
3659
testImplementation("io.github.jadarma.aockt:aockt-test:$aocktVersion")
37-
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
60+
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
3861
}
3962

4063
tasks.test {
4164
useJUnitPlatform()
4265
}
4366
```
67+
</details>
4468

45-
### Project Template
46-
47-
For your convenience, there is an
48-
[advent-of-code-kotlin-template](https://github.com/Jadarma/advent-of-code-kotlin-template) repository which you can
49-
use to generate your own solutions repo, featuring a pre-configured Gradle project, modified source directory locations
50-
for easier navigation, and a detailed README with workflow examples.
51-
If you need a working example, you can check out
52-
[my solutions repo](https://github.com/Jadarma/advent-of-code-kotlin-solutions) as well.
53-
54-
## 📄 Usage Guide
69+
## 🧪 Test DSL Overview
5570

56-
<details open>
57-
<summary>Basic Test Definition</summary>
71+
AocKt provides the following DSL for testing puzzle solutions:
5872

5973
```kotlin
60-
object Y9999D01 : Solution { /* ... */ } // 1.
74+
object Y9999D01 : Solution { // 1.
75+
override fun partOne(input: String) = spoilers()
76+
override fun partTwo(input: String) = spoilers()
77+
}
6178

6279
@AdventDay(9999, 1, "Magic Numbers") // 2.
6380
class Y9999D01Test : AdventSpec<Y9999D01>({ // 3.
@@ -73,7 +90,7 @@ In the above example:
7390

7491
1. Your solution should implement the `Solution` interface.
7592
2. Each test class should be annotated with the `@AdventDay` annotation. Title is optional, but the year and day are
76-
required, so the spec knows what user input to test with.
93+
required.
7794
3. Rather than passing it as an instance, the `AdventSpec` takes in your solution as a type parameter.
7895
4. Use the `partOne` and `partTwo` functions as needed.
7996
Inside the lambda you can define test cases.
@@ -88,139 +105,6 @@ In the above example:
88105
6. As a shorthand for defining multiple examples that should output the same thing, use the `shouldAllOutput` function.
89106
7. If you don't have any examples, but do want to run the part against your input the lambda can be omitted.
90107

91-
</details>
92-
93-
<details>
94-
<summary>Project Configuration</summary>
95-
96-
AocKt provides an extension you may register in your Kotest project to tweak the behaviour of the `AdventSpec`.
97-
Registering it is optional but recommended, and can be done like any other extension:
98-
99-
```kotlin
100-
object TestConfig : AbstractProjectConfig() {
101-
102-
override fun extensions() = listOf<Extension>(
103-
AocKtExtension(),
104-
)
105-
}
106-
```
107-
108-
The following optional parameters exist:
109-
110-
- *formatAdventSpecNames* - When the extension is registered, `AdventSpec` classes have a pretty formatted name in the
111-
test runner. Set this to `false` to opt out of this behavior.
112-
- *efficiencyBenchmark* - If a solution completes under this time value, it will pass its efficiency test.
113-
Lower this value to increase the challenge or increase it to adjust for your hardware *(the latter shouldn't be
114-
necessary)*.
115-
Can be overridden for individual parts, see *Execution Configuration for Parts* for more details.
116-
Default is fifteen seconds.
117-
- *executionMode* - Choose the default execution mode for the entire project (run only examples, only user input, or
118-
all of them).
119-
If set to `ExamplesOnly`, does not run against the true puzzle input even if present.
120-
Useful when running the project with encrypted inputs (e.g. running a clone of someone else's solution repo).
121-
If set to `SkipExamples`, will only test against user input.
122-
Can be overridden for individual parts, see *Execution Configuration for Parts* for more details.
123-
Default is all.
124-
125-
</details>
126-
127-
<details>
128-
<summary>Testing Against User Input</summary>
129-
130-
By default, only the example defined in the DSL will run.
131-
However, the solution can be tested against real user input if it is detected.
132-
AocKt looks inside the test resources directory for them.
133-
The structure is fixed and must match the following:
134-
135-
```text
136-
testResourcesDir
137-
└── aockt
138-
└── y{year}
139-
└── d{two-digit-day}
140-
└── input.txt
141-
└── solution_part1.txt
142-
└── solution_part2.txt
143-
```
144-
145-
If the `input.txt` file exists, the `Solution` will be ran against it after the example tests.
146-
It is normal that at first the solutions are unknown, and therefore missing.
147-
The unverified solution will be added in parens at the end of the test name, which you can then submit to the website.
148-
149-
If the `solution_part1` or `solution_part2.txt` exist, then the value contained within them is assumed to be the correct
150-
output when running against `input.txt`, and will be validated.
151-
152-
**IMPORTANT!:** The reason for keeping the user inputs separate from the tests (apart from readability) is that
153-
[puzzle inputs should not be redistributed](https://old.reddit.com/r/adventofcode/wiki/faqs/copyright/inputs).
154-
If you plan on sharing your solutions repository publicly, either `.gitignore` the `src/test/resources/aockt` directory
155-
or commit them as encrypted blobs only you can read!
156-
157-
</details>
158-
159-
<details>
160-
<summary>Execution configuration for Parts</summary>
161-
162-
The `partOne` and `partTwo` scopes can be configured with optional parameters.
163-
These allow you to modify the way the generated tests behave.
164-
They are mostly meant to help during development, and reverted once your solutions are complete.
165-
166-
The following optional parameters exist:
167-
168-
- *enabled* - True by default. When set to false, all tests for this part are ignored.
169-
Useful for when working on the second part of a puzzle and want to skip re-checking the first when
170-
running the spec.
171-
172-
- *expensive* - False by default. Lowers the time restrictions for execution.
173-
While most puzzles should be solvable in under 15 seconds, sometimes it's hard to come up with an optimised solution
174-
on the first try.
175-
This option tags the tests as slow if you want to exclude them from bulk execution.
176-
177-
- *executionMode* - Defaults to project configuration.
178-
If set to `ExamplesOnly`, does not run against the true puzzle input even if present.
179-
Useful when refactoring an expensive day and no not wish to waste time on the big test while the small ones do fail.
180-
If set to `SkipExamples`, does not run against the example test cases even if present.
181-
Useful for isolating a single execution of the solution, useful when debugging.
182-
183-
- *efficiencyBenchmark* - Defaults to project configuration.
184-
The maximum runtime a solution can have while being considered efficient by the time tests.
185-
Only the user input tests are measured.
186-
187-
</details>
188-
189-
<details>
190-
<summary>Multiple Solutions for the Same Puzzle</summary>
191-
192-
The `AdventSpec` is designed to test a single `Solution` at a time.
193-
However, that doesn't mean you need to duplicate the code if you want to show off multiple approaches to the solution!
194-
You can instead define an abstract specification for your test cases, and use it to derive an arbitrary number of
195-
specific implementation test classes, and supply the `variant` parameter to the `AdventDay` annotation to disambiguate
196-
between the two.
197-
198-
```kotlin
199-
object SolutionA : Solution { /* ... */ }
200-
object SolutionB : Solution { /* ... */ }
201-
202-
@AdventDay(9999, 1, "Magic Numbers", "Variant A")
203-
class SolutionATest : Y9999D01Spec<SolutionA>()
204-
205-
@AdventDay(9999, 1, "Magic Numbers", "Variant B")
206-
class SolutionBTest : Y9999D01Spec<SolutionB>()
207-
208-
abstract class Y9999D01Spec<T : Solution> : AdventSpec<T>({
209-
val exampleInput = "1,2,3,4"
210-
partOne { exampleInput shouldOutput 4 }
211-
partTwo { exampleInput shouldOutput 24 }
212-
})
213-
```
214-
215-
</details>
216-
217-
<details>
218-
<summary>Workflow Example</summary>
219-
220-
For a complete workflow example, check out the
221-
[project template](https://github.com/Jadarma/advent-of-code-kotlin-template#-workflow-example).
222-
</details>
223-
224108
## 👥 Contributing
225109

226110
If you'd like to help out:
@@ -231,4 +115,4 @@ If you'd like to help out:
231115
## ⚖ License
232116

233117
This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) for details.\
234-
_Advent of Code_ is a registered trademark of Eric K Wastl in the United States.
118+
_Advent of Code_ is a registered trademark of Eric K. Wastl in the United States.

docs/topics/overview.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Features and Overview
22

3-
[![Kotlin](https://img.shields.io/badge/Kotlin-%kotlin-version%-%237F52FF.svg?style=flat-square&logo=kotlin&logoColor=%237F52FF)](https://kotlinlang.org/)
4-
[![Kotest](https://img.shields.io/badge/Kotest-%kotest-version%-%35ED35.svg?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+PHBhdGggc3R5bGU9ImZpbGw6IzM1ZWQzNSIgZD0iTTEyIDJoNGwtOCA4IDQgNEg0di00TDAgNmg4WiIvPjwvc3ZnPg==)](https://kotest.io/)
5-
[![Maven Central](https://img.shields.io/maven-central/v/io.github.jadarma.aockt/aockt-test?style=flat-square&color=blue&logo=apachemaven&logoColor=blue&label=Maven%20Central)](https://central.sonatype.com/namespace/io.github.jadarma.aockt)
6-
73
AocKt _(short for Advent of Code - Kotlin)_ is a simple library that makes running and testing your Kotlin solutions to
84
[Advent of Code](https://adventofcode.com) puzzles a breeze.
95

@@ -16,15 +12,23 @@ for testing AoC puzzle solutions with minimal boilerplate.
1612
- **Test-Driven** - Run your code from unit tests for faster feedback loops and fearless refactorings.
1713
- **DSL-Driven** - Define your test cases with minimal code.
1814
- **Configurable** - You decide what runs and when using optional parameters.
19-
- **Minimal** - The test framework is the only non-Kotlin dependency._(short for Advent of Code - Kotlin)_ is a simple library that makes running and testing your Kotlin solutions to
15+
- **Minimal** - The test framework is the only non-Kotlin dependency.
2016

2117
## ⚡ Quick Start
2218

23-
> If you don't want to set up your own project, you can use
24-
> [the AocKt template](https://github.com/Jadarma/advent-of-code-kotlin-template).
25-
> {style="note"}
19+
<tabs>
20+
<tab id="template" title="AocKt Template Project">
21+
For your convenience, there is an
22+
<a href="https://github.com/Jadarma/advent-of-code-kotlin-template"><code>advent-of-code-kotlin-template</code></a>
23+
repository which you can use to generate your own solutions repo.
24+
It comes with a pre-configured Gradle project with all bells and whistles you might need, as well as a modified source
25+
structure for easier navigation.
26+
27+
_(If you need a working example, check out [my solutions repo](https://github.com/Jadarma/advent-of-code-kotlin-solutions).)_
2628

27-
Create a Gradle project with the following build script:
29+
</tab>
30+
<tab id="standalone" title="Standalone Gradle Project">
31+
To add AocKt to your existing project, simply add the dependencies and configure your unit tests to run with Kotest:
2832

2933
```kotlin
3034
plugins {
@@ -45,6 +49,8 @@ tasks.test {
4549
useJUnitPlatform()
4650
}
4751
```
52+
</tab>
53+
</tabs>
4854

4955
## 🧪 Test DSL Overview
5056

docs/topics/workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ projectDir
4242
└── Y2015D01Test.kt
4343
```
4444
</tab>
45-
<tab id="standalone" title="Standalone Project">
45+
<tab id="standalone" title="Standalone Gradle Project">
4646

4747
```text
4848
projectDir

0 commit comments

Comments
 (0)