Quickstart
Dependencies
At the very least, Alerticorn needs its core library and a notifier. Optionally (though recommended), you can add a dependency for integration with your test framework.
- build.gradle.kts
- build.gradle
- pom.xml
dependencies {
testImplementation("nl.vanwollingen.alerticorn:alerticorn-core:1.0.0") //Always required
testImplementation("nl.vanwollingen.alerticorn:alerticorn-slack-notifier:0.1") //To use Slack
testImplementation("nl.vanwollingen.alerticorn:alerticorn-junit:0.1") //Optional: to integrate with JUnit
}
dependencies {
testImplementation 'nl.vanwollingen.alerticorn:alerticorn-core:1.0.0'
testImplementation 'nl.vanwollingen.alerticorn:alerticorn-slack-notifier:0.1'
testImplementation 'nl.vanwollingen.alerticorn:alerticorn-junit:0.1'
}
<dependencies>
<dependency>
<groupId>nl.vanwollingen</groupId>
<artifactId>alerticorn-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.vanwollingen</groupId>
<artifactId>alerticorn-slack-notifier</artifactId>
<version>0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.vanwollingen</groupId>
<artifactId>alerticorn-junit</artifactId>
<version>0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Add Annotations
There's two main ways to use Alerticorn: calling RunWith
directly from your code, or by using Message annotations in
combination with the extension intended for your test framework.
Integrating with JUnit
- Annotate your JUnit test class with the extension
@ExtendWith(MessageExtension::class)
class MyTest {
...
}
- Annotate your JUnit test class or method with @Message.
@Message(title = "The flux capacitator failed")
@Test
fun `flux capacitator test`() {
...
}
Configuration
Set environment variables for the default channel and it's webhook.
It's recommended to not commit your webhooks in code, but rather get them from the environment. Alerticorn will attempt to transform channel names into a webhook url, and fallback to using the raw channel value if no webhook is present in the environment variables.
AC_DEFAULT_CHANNEL="general"
AC_SLACK_CHANNEL_GENERAL="https://hooks.slack.com/services/.../..."
Run your tests as per usual
You can now launch your tests and messages should start to arrive.