{"id":25776949,"url":"https://github.com/laech/java-stacksrc","last_synced_at":"2025-02-27T06:07:03.090Z","repository":{"id":133476554,"uuid":"294075722","full_name":"laech/java-stacksrc","owner":"laech","description":"Decorates stack traces with source code snippets.","archived":false,"fork":false,"pushed_at":"2023-12-07T02:20:29.000Z","size":664,"stargazers_count":239,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2023-12-07T23:30:53.575Z","etag":null,"topics":["gradle","java","junit","maven","testng"],"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/laech.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","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}},"created_at":"2020-09-09T10:11:38.000Z","updated_at":"2023-11-28T15:37:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd69c264-d255-4ec1-9dc1-053cea2d423c","html_url":"https://github.com/laech/java-stacksrc","commit_stats":null,"previous_names":["laech/java-stacksrc"],"tags_count":11,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laech%2Fjava-stacksrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laech%2Fjava-stacksrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laech%2Fjava-stacksrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laech%2Fjava-stacksrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laech","download_url":"https://codeload.github.com/laech/java-stacksrc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889335,"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":["gradle","java","junit","maven","testng"],"created_at":"2025-02-27T06:01:33.322Z","updated_at":"2025-02-27T06:07:03.081Z","avatar_url":"https://github.com/laech.png","language":"Java","readme":"# Overview\n\n\u003cp\u003e\n\u003cpicture\u003e\n  \u003cimg alt=\"Maven Central\" src=\"https://img.shields.io/maven-central/v/nz.lae.stacksrc/stacksrc-core?color=blue\"\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\nThe goal of this project is to decorate stack traces of test failures to make\nthem more useful.\n\nSo instead of getting this when a test fails:\n\n```\norg.opentest4j.AssertionFailedError: expected: \u003chello\u003e but was: \u003chi\u003e\n\tat org.junit...\n\tat com.example.MyTest.hello(MyTest.java:24)\n\t...\n```\n\nYou'll get this:\n\n```\norg.opentest4j.AssertionFailedError: expected: \u003chello\u003e but was: \u003chi\u003e\n\tat org.junit...\n\tat com.example.MyTest.hello(MyTest.java:24)\n\n\t   22    @Test\n\t   23    void compareStrings() {\n\t-\u003e 24      assertEquals(\"hello\", \"hi\");\n\t   25    }\n\n\t...\n```\n\nIn both your IDE and build server test reports. Also works for other JVM\nlanguages.\n\n## Usage\n\nRequires Java 11.\n\n### Gradle\n\n```groovy\ndependencies {\n  // For JUnit 5:\n  testImplementation(\"nz.lae.stacksrc:stacksrc-junit5:${stacksrc.version}\")\n  // For JUnit 4:\n  testImplementation(\"nz.lae.stacksrc:stacksrc-junit4:${stacksrc.version}\")\n  // For TestNG:\n  testImplementation(\"nz.lae.stacksrc:stacksrc-testng:${stacksrc.version}\")\n}\n```\n\n### Maven\n\n```xml\n\n\u003cdependency\u003e\n  \u003cgroupId\u003enz.lae.stacksrc\u003c/groupId\u003e\n  \u003cartifactId\u003estacksrc-junit5\u003c/artifactId\u003e \u003c!-- For JUnit 5 --\u003e\n  \u003cartifactId\u003estacksrc-junit4\u003c/artifactId\u003e \u003c!-- For JUnit 4 --\u003e\n  \u003cartifactId\u003estacksrc-testng\u003c/artifactId\u003e \u003c!-- For TestNG --\u003e\n  \u003cversion\u003e${stacksrc.version}\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### JUnit 5\n\nFor JUnit 5, you can\n[enable automatic extension detection](https://junit.org/junit5/docs/current/user-guide/#extensions-registration-automatic-enabling)\nby setting the system\nproperty `junit.jupiter.extensions.autodetection.enabled=true` on your build,\nthen no other change will be needed for this to work.\n\nIf you don't want to enable automatic extension detection, you can wire things\nup manually using either JUnit's `@ExtendWith` or `@RegisterExtension` like the\nfollowing, then all tests inheriting `BaseTest` will have their stack traces\ndecorated on failure:\n\n```java\n\n@ExtendWith(ErrorDecorator.class)\nclass BaseTest {\n}\n\nclass MyTest extends BaseTest {\n  @Test\n  void myTest() {\n    // ...\n  }\n}\n```\n\n### JUnit 4\n\nFor JUnit 4, create a base test with a test rule, then all tests\ninheriting `BaseTest` will have their stack traces\ndecorated on failure:\n\n```java\npublic class BaseTest {\n  @Rule\n  public final ErrorDecorator errorDecorator = new ErrorDecorator();\n}\n\npublic final class MyTest extends BaseTest {\n  @Test\n  public void myTest() {\n    // ...\n  }\n}\n```\n\n### TestNG\n\nNo extra work is needed apart from adding the dependency.\n","funding_links":[],"categories":["测试"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaech%2Fjava-stacksrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaech%2Fjava-stacksrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaech%2Fjava-stacksrc/lists"}