Skip to main content

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.

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
}

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

  1. Annotate your JUnit test class with the extension
@ExtendWith(MessageExtension::class)
class MyTest {
...
}
  1. 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.