{"id":21832040,"url":"https://github.com/dailymotion/allure-go","last_synced_at":"2025-04-19T15:10:11.665Z","repository":{"id":41368089,"uuid":"212299906","full_name":"dailymotion/allure-go","owner":"dailymotion","description":"Golang port for Allure test reporting tool","archived":false,"fork":false,"pushed_at":"2024-09-26T16:47:31.000Z","size":123,"stargazers_count":78,"open_issues_count":3,"forks_count":18,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-29T09:11:37.290Z","etag":null,"topics":["allure","golang","reporting-tool"],"latest_commit_sha":null,"homepage":"","language":"Go","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/dailymotion.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-02T09:22:16.000Z","updated_at":"2024-12-12T03:20:12.000Z","dependencies_parsed_at":"2024-09-05T20:32:42.973Z","dependency_job_id":"832cf31e-dc12-4eca-85b2-7c6330dead75","html_url":"https://github.com/dailymotion/allure-go","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailymotion%2Fallure-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailymotion%2Fallure-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailymotion%2Fallure-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dailymotion%2Fallure-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dailymotion","download_url":"https://codeload.github.com/dailymotion/allure-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249722855,"owners_count":21315899,"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":["allure","golang","reporting-tool"],"created_at":"2024-11-27T19:17:24.619Z","updated_at":"2025-04-19T15:10:11.640Z","avatar_url":"https://github.com/dailymotion.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Allure Golang Integration\n\n`allure-go` is a Go package that provides all required tools to transform your tests into [Allure](https://github.com/allure-framework/allure2) reports.\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Usage](#usage)\n    1. [Specifying `allure-results` folder location](#specifying-allure-results-folder-location)\n    2. [Optional environment variable](#optional-environment-variable) \n3. [Features](#features)\n    1. [Test Wrapper](#test-wrapper)\n    2. [Nested Steps](#nested-steps)\n    3. [Option Slices](#option-slices)\n        1. [Description](#description)\n        2. [Action](#action)\n        3. [Parameter](#parameter)\n        4. [Parameters](#parameters)\n    4. [Test-specific options](#test-specific-options)\n        1. [Lead](#lead)\n        2. [Owner](#owner)\n        3. [Epic](#epic)\n        4. [Severity](#severity)\n        5. [Story](#story)\n        6. [Feature](#feature)\n    4. [Parameters](#parameters-as-a-feature)\n    5. [Attachments](#attachments)\n    6. [Setup/Teardown](#setupteardown)\n    7. [Environment files](#environment-files)\n4. [Feature Roadmap](#feature-roadmap) \n\n\n## Installation\nIn order to retrieve `allure-go` simply run the following command (assuming `Go` is installed):\n```sh\n$ go get -u github.com/dailymotion/allure-go\n```\n\n## Usage\n\n### Specifying allure-results folder location\nGolang's approach to evaluating test scripts does not allow to establish a single location for test results \nprogrammatically, the following environment variable is required for `allure-go` to work as expected. \nIn order to specify the location of a report run the following:\n```shell script\nexport ALLURE_RESULTS_PATH=\u003c/some/path\u003e\n```\n\n`allure-results` folder will be created in that location. \n\n### Optional environment variable\nAllure-go will retrieve the absolute path of your testing files (for example, /Users/myuser/Dev/myProject/tests/myfile_test.go) and will display this path in the reports.\n\nTo make it cleaner, you can trim prefix the path of your project by defining the `ALLURE_WORKSPACE_PATH` with the value of your project root path :\n```shell script\nexport ALLURE_WORKSPACE_PATH=/another/path\n```\n\nYou will now get the relative path of your test files from your project root level.\n\n## Features\n\n### Test Wrapper\n`allure-go` test reporting relies on wrapping test scripts inside a call to `allure.Test()` function:\n```go\nallure.Test(t *testing.T, testOptions ...Option)\n```\nThis function allows adding required modules representing a test along with additional non-essential modules like labels.\nFor basic usage refer to the following example:\n```go\npackage test\n\nimport (\n        \"fmt\"\n        \"github.com/dailymotion/allure-go\"\n        \"testing\"\n)\n \nfunc TestStep(t *testing.T) {\n    allure.Test(t, allure.Action(func() {\n                    fmt.Println(\"This block of code is a test\")\n                }))\n}\n```  \n\n### Nested Steps\n`allure-go` takes advantage of Allure Reports feature of nested steps and allows marking portions of the code as steps \neven if said portions are found outside test scripts in functions that are eventually called by a test script.\nThis is a great feature for enabling levels of detail for test reporting.\n```go\npackage test\n\nimport (\n        \"fmt\"\n        \"github.com/dailymotion/allure-go\"\n        \"testing\"\n)\n \nfunc TestStep(t *testing.T) {\n    allure.Test(t, allure.Action(func() {\n                    allure.Step(allure.Description(\"Action\"),\n                                    allure.Action(func() {\n                                            fmt.Println(\"This block of code is a step\")\n                                    }))\n                    PerformAction()\n                }))\n}\n\nfunc PerformAction() {\n    allure.Step(allure.Description(\"Action\"),\n                allure.Action(func() {\n                        fmt.Println(\"This block of code is also a step\")\n                }))\n}\n```\n\n### Option Slices\nOption slices allow providing as much or as little detail for the test scripts as needed.\n\n#### Description\n```go\nallure.Description(\"Description of a test or a step\")\n```\nProvides a name for the step and a description for the test. This option is required\n \n#### Action\n```go\nallure.Action(func() {})\n```\nThis option is a wrapper for the portion of code that is either your test or your step. This option is required.\n\n#### Parameter\n```go\nallure.Parameter(name string, value interface{})\n```\nThis option specifies parameters for the test or step accordingly.\nThis particular option can be called multiple times to add multiple parameters.\n\n#### Parameters\n```go\nallure.Parameters(parameters map[string]interface{})\n```\nThis option allows specifying multiple parameters at once. \nThis option can be called multiple times as well and will not interfere with previous parameter assignments.\n\n### Test-specific options\n\n#### Lead\n```go\nallure.Lead(lead string)\n```\nThis option specifies a lead of the feature.\n\n#### Owner\n```go\nallure.Owner(owner string)\n```\nThis option specifies an owner of the feature.\n\n#### Epic\n```go\nallure.Epic(epic string)\n```\nThis option specifies an epic this test belongs to.\n\n#### Severity\n```go\nallure.Severity(severity severity.Severity)\n```\nThis option specifies a severity level of the test script to allow better prioritization.\n\n#### Story\n```go\nallure.Story(story string)\n```\nThis option specifies a story this test script belongs to. \nThis particular option can be called multiple times to connect this test script to multiple stories. \n\n#### Feature\n```go\nallure.Feature(feature string)\n```\nThis option specifies a feature this test script belongs to.\nThis particular option can be called multiple times to connect this test script to multiple features.\n\n### Parameters as a feature\n`allure-go` allows specifying parameters on both test and step level to further improvement informativeness of your \ntest scripts and bring it one step closer to being documentation. \nIn order to specify a parameter refer to the following example:\n```go\npackage test\n\nimport (\n           \"github.com/dailymotion/allure-go\"\n           \"testing\"\n        )     \n\nfunc TestParameter(t *testing.T) {\n    allure.Test(t, \n                allure.Description(\"Test that has parameters\"),\n                allure.Parameter(\"testParameter\", \"test\"),\n                allure.Action(func() {\n                    allure.Step(allure.Description(\"Step with parameters\"),\n                                allure.Action(func() {}),\n                                allure.Parameter(\"stepParameter\", \"step\"))\n                }))\n}\n```\nAllure parameters integrate neatly with Golang's parameterized tests too:\n```go\npackage test\n\nimport (\n           \"github.com/dailymotion/allure-go\"\n           \"testing\"\n        )\n\nfunc TestParameterized(t *testing.T) {\n    for i := 0; i \u003c 5; i++ {\n    \t\tt.Run(\"\", func(t *testing.T) {\n    \t\t\tallure.Test(t,\n    \t\t\t\tallure.Description(\"Test with parameters\"),\n    \t\t\t\tallure.Parameter(\"counter\", i),\n    \t\t\t\tallure.Action(func() {}))\n    \t\t})\n    \t}\n}\n```\n\n### Attachments\n`allure-go` providing an ability to attach content of various MIME types to test scripts and steps.\nThe most common MIME types are available as constants in `allure-go` \n(`image/png`, `application/json`, `text/plain` and `video/mpeg`).\nIn order to attach content to a test or step refer to the following example:\n```go\npackage test\n\nimport (\n            \"errors\"\n            \"github.com/dailymotion/allure-go\"\n            \"log\"\n            \"testing\"\n   )\n\nfunc TestImageAttachmentToStep(t *testing.T) {\n\tallure.Test(t, \n        allure.Description(\"testing image attachment\"), \n        allure.Action(func() {\n            allure.Step(allure.Description(\"adding an image attachment\"), \n                allure.Action(func() {\n                    err := allure.AddAttachment(\"image\", allure.ImagePng, []byte(\"\u003cbyte array representing an image\u003e\"))\n                    if err != nil {\n                        log.Println(err)\n                    }\n        }))\n\t}))\n}\n```\n\n### Setup/Teardown\nGolang does not directly follow the setup/teardown approach of other languages like Java, C# and Python.\nThis does not prevent us from logically separating said phases in test scripts and taking \nadvantage of separating these phases in the test reports too.\n`allure.BeforeTest` and `allure.AfterTest` functions have to be called in sequence with the test wrapper.\n\n`allure.BeforeTest` goes first, then `allure.Test` and finally `allure.AfterTest`. \nThis is done to allow various logical conclusions, such as upon failure of `allure.BeforeTest` actual test body \nwill be skipped, etc.\n\nPlease refer to the following example of setup/teardown usage:\n```go\npackage test\n\nimport (\n        \"github.com/dailymotion/allure-go\"\n        \"testing\"\n)\nfunc TestAllureSetupTeardown(t *testing.T) {\n\tallure.BeforeTest(t,\n\t\tallure.Description(\"setup\"),\n\t\tallure.Action(func() {\n\t\t\tallure.Step(\n\t\t\t\tallure.Description(\"Setup step 1\"),\n\t\t\t\tallure.Action(func() {}))\n\t\t}))\n\n\tallure.Test(t,\n\t\tallure.Description(\"actual test\"),\n\t\tallure.Action(func() {\n\t\t\tallure.Step(\n\t\t\t\tallure.Description(\"Test step 1\"),\n\t\t\t\tallure.Action(func() {}))\n\t\t}))\n\n\tallure.AfterTest(t,\n\t\tallure.Description(\"teardown\"),\n\t\tallure.Action(func() {\n\t\t\tallure.Step(\n\t\t\t\tallure.Description(\"Teardown step 1\"),\n\t\t\t\tallure.Action(func() {}))\n\t\t}))\n}\n```  \nIn case of utilizing setup/teardown in a parameterized test, all of the test phases have to be called \ninside `t.Run(...)` call.\n\n### Environment Files\n`allure-go` allows taking advantage of the environment file feature of Allure reports. You can specify report-specific \nvariables that you want to appear in the report such as browser kind and version, OS, environment name, etc.\nIn order to do that create an `environment.xml` or `environment.properties` file as instructed [here](https://docs.qameta.io/allure/#_environment) and define an\nenvironment variable for `allure-go` to incorporate in the results:\n```shell script\nexport ALLURE_ENVIRONMENT_FILE_PATH=\u003cpath to environment file\u003e\n```\n\n## Feature Roadmap\n`allure-go` is still in active development and is not yet stabilized or finalized.\n\nHere is a list of improvements that are needed for existing features :\n- [X] Manage failure at step level : the project must be able to mark a Step as failed (red in the report) when an assertion fails. The assertion stacktrace must appear in the report.\n- [X] Manage error at test and step level : the project must be able to mark a Test and Step as broken (orange in the report) when an error happens. The error stacktrace must appear in the report.\n- [X] Add support of Links\n- [ ] Add support of Unknown status for Test object\n- [X] Add support of Set up in Execution part of a Test\n- [X] Add support of Tear down in Execution part of a Test\n- [X] Add support of Severity\n- [ ] Add support of Flaky tag\n- [X] Add support of Categories\n- [X] Add support of Features\n- [X] Add support for environment files\n- [ ] Add support for history","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdailymotion%2Fallure-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdailymotion%2Fallure-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdailymotion%2Fallure-go/lists"}