Merged
Conversation
1. Step/fixture functions moved from CoreStepsHelper to Allure 2. Unit tests adjusted 3. Add info about Allure to README 4. Adjust examples to use Allure 5. Make CoreStepsHelper and its subclasses obsoleted Related to #404
Also remove AddParameter from TestResult (discussed).
Related to #404
Otherwise, there would be conflict between the class name and the root namespace name. Related to #404
- SetTestParameter and UpdateTestParameter for adding and updating test parameters - historyId calculation adjusted to ignore excluded parameters - enum JSON serialization changed to camelcase (shouldn't affect anything) Related to #404
Motivation: more reliable, always takes into account the latest parameter set.
baev
approved these changes
Nov 15, 2023
- Move StepLogger from AllureApi back to CoreStepsHelper - Mark StepLogger as obsoleted - Remove step logging example from NUnit examples Related to #404
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This PR introduces the runtime API that targets authors of tests. Prior to this, they had to use the low-level API of AllureLifecycle (the API designed primarily for authors of integrations).
Motivation
1. Make report enhancements at runtime more convenient and straightforward for test authors.
Currently, they have to use a lot of boilerplate code to enhance the report. For example, adding a set of BDD labels to the test at runtime requires the following code:
The test author's runtime API allows it to be done with this instead:
Only the function call and the name of the feature must be expressed now.
2. Provide an intermediate API layer that can be used by higher level APIs.
Example of such high-level API could be the attribute-based (i.e., compile time) API. Currently, we have two different implementations of such API for NUnit and xUnit.net.
API changes
The Runtime API is split into two sets of functions. The most commonly used are defined in
AllureApi. The low-level functions and rarely used ones are defined inExtendedApi.All examples have been updated to use those functions.
The
Allure.Net.Commons.AllureApiclassThis is a facade that provides a set of commonly used functions designed for test authors. All functions are implemented as static methods. Some functions are brand new. Attachment-related functions were moved from AllureLifecycle. Step-related functions were moved from CoreStepsHelper.
Note
The class is named
AllureApiinstead of justAllureas in allure-java because otherwise, it would conflict with theAllurenamespace.Here is the complete list of the runtime API functions in
AllureApi:The
Allure.Net.Commons.ExtendedApiclassHere is the complete list of the runtime API functions in
ExtendedApi:Deprecations
All public members inside
Allure.Net.Commons.Steps.CoreStepsHelperare obsolete now. Additionally, all attachment-related functions insideAllure.Net.Commons.AllureLifecycleand theAllure.Net.Commons.TestResult.AddParametermethod are all deprecated.The following functions were deprecated by this PR in favor of the new test author's runtime API:
Allure.Net.Commons.Steps.CoreStepsHelper.StartBeforeFixture(string name) : voidAllure.Net.Commons.Steps.CoreStepsHelper.StartAfterFixture(string name) : voidAllure.Net.Commons.Steps.CoreStepsHelper.PassFixture() : voidAllure.Net.Commons.Steps.CoreStepsHelper.PassFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.FailFixture() : voidAllure.Net.Commons.Steps.CoreStepsHelper.FailFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.BrokeFixture() : voidAllure.Net.Commons.Steps.CoreStepsHelper.BrokeFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.StartStep(string name) : voidAllure.Net.Commons.Steps.CoreStepsHelper.StartStep(string name, Action<Allure.Net.Commons.StepResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.PassStep() : voidAllure.Net.Commons.Steps.CoreStepsHelper.PassStep(Action<Allure.Net.Commons.StepResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.FailStep() : voidAllure.Net.Commons.Steps.CoreStepsHelper.FailStep(Action<Allure.Net.Commons.StepResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.BrokeStep() : voidAllure.Net.Commons.Steps.CoreStepsHelper.BrokeStep(Action<Allure.Net.Commons.StepResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.Step(string name) : voidAllure.Net.Commons.Steps.CoreStepsHelper.Step(string name, Action action) : voidAllure.Net.Commons.Steps.CoreStepsHelper.Step<T>(string name, Func<T> action) : TAllure.Net.Commons.Steps.CoreStepsHelper.Step(string name, Func<Task> action) : TaskAllure.Net.Commons.Steps.CoreStepsHelper.Step<T>(string name, Func<Task<T>> action) : Task<T>Allure.Net.Commons.Steps.CoreStepsHelper.Before(string name, Action action) : voidAllure.Net.Commons.Steps.CoreStepsHelper.Before<T>(string name, Func<T> action) : TAllure.Net.Commons.Steps.CoreStepsHelper.Before(string name, Func<Task> action) : TaskAllure.Net.Commons.Steps.CoreStepsHelper.Before<T>(string name, Func<Task<T>> action) : Task<T>Allure.Net.Commons.Steps.CoreStepsHelper.After(string name, Action action) : voidAllure.Net.Commons.Steps.CoreStepsHelper.After<T>(string name, Func<T> action) : TAllure.Net.Commons.Steps.CoreStepsHelper.After(string name, Func<Task> action) : TaskAllure.Net.Commons.Steps.CoreStepsHelper.After<T>(string name, Func<Task<T>> action) : Task<T>Allure.Net.Commons.AllureLifecycle.AddAttachment(string name, string type, string path) : voidAllure.Net.Commons.AllureLifecycle.AddAttachment(string name, string type, byte[] content, string fileExtension = "") : voidAllure.Net.Commons.AllureLifecycle.AddAttachment(string path, string? name = null) : voidAllure.Net.Commons.AllureLifecycle.AddScreenDiff(string expectedPng, string actualPng, string diffPng) : voidAllure.Net.Commons.TestResult.AddParameter(string name, object value, IReadOnlyDictionary<Type, Allure.Net.Commons.ITypeFormatter> formatters) : voidWe advise users to move to their
Allure.Net.Commons.AllureApi's counterparts. The functions mostly remained the name and the parameters. The only exceptions are theBrokeXmethods what were renamed toBreakXinAllureApi..The following functions were deprecated by this PR as duplicates of the existing AllureLifecycle's methods:
Allure.Net.Commons.Steps.CoreStepsHelper.StopFixture() : voidAllure.Net.Commons.Steps.CoreStepsHelper.StopFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : voidAllure.Net.Commons.Steps.CoreStepsHelper.UpdateTestResult(Action<Allure.Net.Commons.TestResult> update) : voidWe advise test authors to consider using the new API instead and only if that's not possible - the corresponding methods of the current lifecycle object (referenced by the
AllureLifecycle.Instanceproperty).The following property was deprecated:
Allure.Net.Commons.Steps.CoreStepsHelper.StepLogger { get; set; } : IStepLogger?It will be replaced with event listeners in the future.
Other changes
The PR contains the following additional changes:
Parameter's
modeandexcludeoptions (#425)Parameter.mode: ParameterModeandParameter.exclude: boolwere added to the object model.IdFunctions.CreateHistoryIdwas adjusted to not take into account excluded parameters.Xml documentation for Allure.Net.Commons (#426)
The
Allure.Net.Commonspackage now includes an XML doc file that is used by IDE's to provide users with API discovery and code completion. Structured comments were added to most public functions of the package.XML doc files for other packages will be added later.
historyId calculation fix
Now historyId is calculated lately, in
StopTestCasebased on fullName and parameters of the test. This allows parameters added at runtime to be taken into account. Additionally, that fixes missinghistoryIdfor skipped xUnit theories (see #422).Fix encoding for JSON schemas (see #415)
To comply with RFC 8259, byte order marks were removed from the JSON schemas:
Fix link factory methods (#416)
Allure.Net.Commons.Link.Issue(string name): Allure.Net.Commons.LinkandAllure.Net.Commons.Link.Tms(string name): Allure.Net.Commons.Linkwere fixed to fill theurlfield. The methods essentially use the provided URL as the name of the link, so in both cases, the parameter was renamed fromnametourl.Fix flaky InvalidOperationException when running SpecFlow tests (#433)
This error occurs because of some rudimentary code that was left from an earlier attempt to implement a selective run in Allure SpecFlow. The code isn't needed now and was removed in this PR.
Checklist
Closes #404
Closes #415
Closes #416
Closes #422
Closes #425
Partially implements #426
Closes #433