{"id":15597979,"url":"https://github.com/nalbion/test-appender","last_synced_at":"2025-10-24T19:39:01.891Z","repository":{"id":59358334,"uuid":"533742756","full_name":"nalbion/test-appender","owner":"nalbion","description":"Allows logging output of Java applications to be tested ","archived":false,"fork":false,"pushed_at":"2023-09-06T04:59:17.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T07:44:54.031Z","etag":null,"topics":["logger","logging","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nalbion.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-07T11:51:54.000Z","updated_at":"2023-05-15T23:33:27.000Z","dependencies_parsed_at":"2024-12-16T03:42:35.036Z","dependency_job_id":"02996bb1-feb8-4a8a-975e-9f31c1ae3c4b","html_url":"https://github.com/nalbion/test-appender","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":0.09999999999999998,"last_synced_commit":"ff5f9954a14d3422cf8c0b47d4f54847cebf5586"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/nalbion/test-appender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalbion%2Ftest-appender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalbion%2Ftest-appender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalbion%2Ftest-appender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalbion%2Ftest-appender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nalbion","download_url":"https://codeload.github.com/nalbion/test-appender/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nalbion%2Ftest-appender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280857646,"owners_count":26403192,"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","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["logger","logging","testing"],"created_at":"2024-10-03T01:25:15.821Z","updated_at":"2025-10-24T19:39:01.875Z","avatar_url":"https://github.com/nalbion.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test Appender\n![Release Pipeline Status](https://github.com/nalbion/test-appender/actions/workflows/maven-publish.yml/badge.svg)\n[![Sonartype Lift status](https://lift.sonatype.com/api/badge/github.com/nalbion/test-appender)](https://lift.sonatype.com/results/github.com/nalbion/test-appender)\n\nBy taking TDD one step further, and specifying what the logging output should look like before writing the code \nwe can expect that the logs will give maintainers clear and useful logs.\n\nBased on Jaroslaw Michalik's article [Don't mock static: test SLF4J Logger with appenders](https://kotlintesting.com/mock-slf4j/).\n\nFor JavaScript applications, refer to [log-dd](https://github.com/nalbion/log-dd).\n\n`TestAppender` assumes that the application uses `ch.qos.logback.classic.Logger`, which is the default provided by Spring Boot.\n\n## Installation\n\nThis library is available from [Maven Central](https://s01.oss.sonatype.org/) or \n[Git Hub Packages](https://github.com/nalbion/test-appender/packages)\n\n### Gradle\n```groovy\ndependencies {\n    ...\n    testImplementation 'io.github.nalbion:test-appender:1.0.3'\n}\n```\n\n### Maven\n```xml\n  \u003cdependencies\u003e\n    ...\n    \u003cdependency\u003e\n      \u003cgroupId\u003eio.github.nalbion\u003c/groupId\u003e\n      \u003cartifactId\u003etest-appender\u003c/artifactId\u003e\n      \u003cversion\u003e1.0.3\u003c/version\u003e\n      \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n  \u003c/dependencies\u003e\n```\n\n## Usage\n\n```java\n...\nimport io.github.nalbion.TestAppender;\nimport org.junit.jupiter.api.Test;\n\nclass MyTest {\n    private final TestAppender testAppender = new TestAppender(true);\n\n    @BeforeEach\n    void setup() {\n        testAppender.start();\n    }\n\n    @Test\n    void myTest() {\n        // When\n        new MyApplication().doSomething();\n\n        // Then\n        // Check all logs match a multi-line string\n        testAppender.assertLogs(\"\"\"\n                Hello World!\n                My application calls log.info() twice.\"\"\");\n\n        // Check that only some lines are logged at WARN\n        testAppender.assertLogs(Level.WARN, \"My application calls log.info() twice.\");\n\n        // Check that at least one of the lines matches a Predicate\n        testAppender.assertAnyLogs(\n                TestAppender.atLogLevel(Level.INFO)\n                        .and(e -\u003e e.getFormattedMessage().matches(\"Hello .*!\"))\n        );\n\n        testAppender.assertNoLogs(e -\u003e e.getFormattedMessage().matches(\"Password: .*!\"));\n    }\n\n    @Test\n    void dynamicValues() {\n        // When\n        logger.info(\"The time is {}\", new SimpleDateFormat(\"HH:mm\").format(new Date()));\n        \n        // Then\n        // Handle dynamic values - date/time, random values\n        testAppender.assertLogs(line -\u003e line.replaceFirst(\"\\\\b\\\\d{1,2}:\\\\d{2}\\\\b\", \"hh:mm\"),\n                \"The time is hh:mm\");     \n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnalbion%2Ftest-appender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnalbion%2Ftest-appender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnalbion%2Ftest-appender/lists"}