-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime API #414
Merged
Merged
Runtime API #414
Conversation
This file contains 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
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.
delatrie
added
the
task:improvement
Change that improves some user experience but can't be considered a new feature
label
Nov 10, 2023
github-actions
bot
added
theme:build
theme:specflow
theme:core
theme:xunit
theme:nunit
and removed
task:improvement
Change that improves some user experience but can't be considered a new feature
labels
Nov 10, 2023
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
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.AllureApi
classThis 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
AllureApi
instead of justAllure
as in allure-java because otherwise, it would conflict with theAllure
namespace.Here is the complete list of the runtime API functions in
AllureApi
:The
Allure.Net.Commons.ExtendedApi
classHere is the complete list of the runtime API functions in
ExtendedApi
:Deprecations
All public members inside
Allure.Net.Commons.Steps.CoreStepsHelper
are obsolete now. Additionally, all attachment-related functions insideAllure.Net.Commons.AllureLifecycle
and theAllure.Net.Commons.TestResult.AddParameter
method 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) : void
Allure.Net.Commons.Steps.CoreStepsHelper.StartAfterFixture(string name) : void
Allure.Net.Commons.Steps.CoreStepsHelper.PassFixture() : void
Allure.Net.Commons.Steps.CoreStepsHelper.PassFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.FailFixture() : void
Allure.Net.Commons.Steps.CoreStepsHelper.FailFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.BrokeFixture() : void
Allure.Net.Commons.Steps.CoreStepsHelper.BrokeFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.StartStep(string name) : void
Allure.Net.Commons.Steps.CoreStepsHelper.StartStep(string name, Action<Allure.Net.Commons.StepResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.PassStep() : void
Allure.Net.Commons.Steps.CoreStepsHelper.PassStep(Action<Allure.Net.Commons.StepResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.FailStep() : void
Allure.Net.Commons.Steps.CoreStepsHelper.FailStep(Action<Allure.Net.Commons.StepResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.BrokeStep() : void
Allure.Net.Commons.Steps.CoreStepsHelper.BrokeStep(Action<Allure.Net.Commons.StepResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.Step(string name) : void
Allure.Net.Commons.Steps.CoreStepsHelper.Step(string name, Action action) : void
Allure.Net.Commons.Steps.CoreStepsHelper.Step<T>(string name, Func<T> action) : T
Allure.Net.Commons.Steps.CoreStepsHelper.Step(string name, Func<Task> action) : Task
Allure.Net.Commons.Steps.CoreStepsHelper.Step<T>(string name, Func<Task<T>> action) : Task<T>
Allure.Net.Commons.Steps.CoreStepsHelper.Before(string name, Action action) : void
Allure.Net.Commons.Steps.CoreStepsHelper.Before<T>(string name, Func<T> action) : T
Allure.Net.Commons.Steps.CoreStepsHelper.Before(string name, Func<Task> action) : Task
Allure.Net.Commons.Steps.CoreStepsHelper.Before<T>(string name, Func<Task<T>> action) : Task<T>
Allure.Net.Commons.Steps.CoreStepsHelper.After(string name, Action action) : void
Allure.Net.Commons.Steps.CoreStepsHelper.After<T>(string name, Func<T> action) : T
Allure.Net.Commons.Steps.CoreStepsHelper.After(string name, Func<Task> action) : Task
Allure.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) : void
Allure.Net.Commons.AllureLifecycle.AddAttachment(string name, string type, byte[] content, string fileExtension = "") : void
Allure.Net.Commons.AllureLifecycle.AddAttachment(string path, string? name = null) : void
Allure.Net.Commons.AllureLifecycle.AddScreenDiff(string expectedPng, string actualPng, string diffPng) : void
Allure.Net.Commons.TestResult.AddParameter(string name, object value, IReadOnlyDictionary<Type, Allure.Net.Commons.ITypeFormatter> formatters) : void
We 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 theBrokeX
methods what were renamed toBreakX
inAllureApi
..The following functions were deprecated by this PR as duplicates of the existing AllureLifecycle's methods:
Allure.Net.Commons.Steps.CoreStepsHelper.StopFixture() : void
Allure.Net.Commons.Steps.CoreStepsHelper.StopFixture(Action<Allure.Net.Commons.FixtureResult> updateResults) : void
Allure.Net.Commons.Steps.CoreStepsHelper.UpdateTestResult(Action<Allure.Net.Commons.TestResult> update) : void
We 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.Instance
property).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
mode
andexclude
options (#425)Parameter.mode: ParameterMode
andParameter.exclude: bool
were added to the object model.IdFunctions.CreateHistoryId
was adjusted to not take into account excluded parameters.Xml documentation for Allure.Net.Commons (#426)
The
Allure.Net.Commons
package 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
StopTestCase
based on fullName and parameters of the test. This allows parameters added at runtime to be taken into account. Additionally, that fixes missinghistoryId
for 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.Link
andAllure.Net.Commons.Link.Tms(string name): Allure.Net.Commons.Link
were fixed to fill theurl
field. The methods essentially use the provided URL as the name of the link, so in both cases, the parameter was renamed fromname
tourl
.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