{"id":20292762,"url":"https://github.com/neuland/assertj-logging","last_synced_at":"2025-10-11T05:03:20.294Z","repository":{"id":44642862,"uuid":"265483703","full_name":"neuland/assertj-logging","owner":"neuland","description":"Easy assertj logging assertions ","archived":false,"fork":false,"pushed_at":"2023-04-01T14:02:13.000Z","size":112,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-25T07:41:42.037Z","etag":null,"topics":["assertj","assertj-assertions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neuland.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-20T07:21:33.000Z","updated_at":"2024-09-19T13:39:23.000Z","dependencies_parsed_at":"2022-09-26T21:51:05.629Z","dependency_job_id":null,"html_url":"https://github.com/neuland/assertj-logging","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuland%2Fassertj-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuland%2Fassertj-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuland%2Fassertj-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuland%2Fassertj-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuland","download_url":"https://codeload.github.com/neuland/assertj-logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248382244,"owners_count":21094552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertj","assertj-assertions"],"created_at":"2024-11-14T15:19:10.624Z","updated_at":"2025-10-11T05:03:15.252Z","avatar_url":"https://github.com/neuland.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assertj-logging - assertj assertions for logging\n\n_assertj-logging_'s intention is to provide an easy way to unit test expected logging for different logging implementations with [JUnit](https://junit.org/) and [AssertJ](https://assertj.github.io/doc/).\n\nStarting with version 0.5.0 a [JUnit 5 extension](https://junit.org/junit5/docs/current/user-guide/#extensions) is provided and [JUnit 4](https://junit.org/junit4/) is no longer supported.\n\nVersions up to 0.4.X provide a [JUnit 4 `@Rule`](https://github.com/junit-team/junit4/wiki/Rules).\n\nIt currently supports\n* [log4j 2.x](https://logging.apache.org/log4j/2.x/): _assertj-logging-log4j_\n* [logback](http://logback.qos.ch/): _assertj-logging-logback_\n\n\n## Contents\n\n- [Configuration](#configuration)\n- [How it works](#how-it-works)\n- [Usage](#usage)\n\n\n## Configuration\n\n### Gradle\n\n_build.gradle_\n\n```$groovy\ndependencies {\n    testImplementation 'de.neuland-bfi:assertj-logging-log4j:0.4.0'\n}\n```\n\n### Maven\n\n_pom.xml_\n\n```$xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.neuland-bfi\u003c/groupId\u003e\n    \u003cartifactId\u003eassertj-logging-log4j\u003c/artifactId\u003e\n    \u003cversion\u003e0.5.0\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## How it works\n\n_assert-logging_ provides a JUnit rule that adds an appender to capture log messages to the logger of the logging source (the class emitting log messages).\n\nAfter execution of the code under test this rule can be fed to a set of AssertJ assertions to verify that the expected logging was emitted.\n\n## Usage\n\n### JUnit 5\n\n```java\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.extension.RegisterExtension;\n\nimport de.neuland.assertj.logging.ExpectedLogging;\n\nimport static de.neuland.assertj.logging.ExpectedLoggingAssertions.assertThat;\n\npublic class LoggingSourceTest {\n    @RegisterExtension\n    private final ExpectedLogging logging = ExpectedLogging.forSource(LoggingSource.class);\n\n    @Test\n    void shouldCaptureLogging() {\n        // given\n        String expectedMessage = \"Error Message\";\n\n        // when\n        new LoggingSource().doSomethingThatLogsErrorMessage();\n\n        // then\n        assertThat(logging).hasErrorMessage(expectedMessage);\n    }\n}\n```\n\n### JUnit 4\n```java\nimport org.junit.Rule;\nimport org.junit.Test;\n\nimport de.neuland.assertj.logging.ExpectedLogging;\n\nimport static de.neuland.assertj.logging.ExpectedLoggingAssertions.assertThat;\n\npublic class LoggingSourceTest {\n    @Rule\n    public ExpectedLogging logging = ExpectedLogging.forSource(LoggingSource.class);\n\n    @Test\n    public void shouldCaptureLogging() {\n        // given\n        String expectedMessage = \"Error Message\";\n\n        // when\n        new LoggingSource().doSomethingThatLogsErrorMessage();\n\n        // then\n        assertThat(logging).hasErrorMessage(expectedMessage);\n    }\n}\n```\n\n### Supported Log Levels\n\nWe consider _ERROR_, _WARNING_ and _INFO_ to be the test-worthy log levels.\n\nThus, _assertj-logging_ provides assertions for these log levels.\n\n### Assertions\n\nThe following assertions are available:\n\n```java\nassertThat(logging).hasErrorMessage(String message);\nassertThat(logging).hasNoErrorMessage();\nassertThat(logging).hasErrorMessage(String message, Throwable throwable);\nassertThat(logging).hasErrorMessageMatching(String regex);\nassertThat(logging).hasErrorMessageMatching(String regex, Throwable throwable);\n\nassertThat(logging).hasWarningMessage(String message);\nassertThat(logging).hasNoWarningMessage();\nassertThat(logging).hasWarningMessage(String message, Throwable throwable);\nassertThat(logging).hasWarningMessageMatching(String regex);\nassertThat(logging).hasWarningMessageMatching(String regex, Throwable throwable);\n\nassertThat(logging).hasInfoMessage(String message);\nassertThat(logging).hasNoInfoMessage();\nassertThat(logging).hasInfoMessageMatching(String regex);\n```\n\nAll assertions from AssertJ's [ListAssert](https://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/ListAssert.html) are available as well, e.g.\n\n```java\nassertThat(logging).isEmpty();\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuland%2Fassertj-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuland%2Fassertj-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuland%2Fassertj-logging/lists"}