Skip to content
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

Simplify test idioms to build a project and assert the status #43

Open
jglick opened this issue Aug 23, 2023 · 0 comments
Open

Simplify test idioms to build a project and assert the status #43

jglick opened this issue Aug 23, 2023 · 0 comments
Labels
recipe Requests for new automated code changes

Comments

@jglick
Copy link

jglick commented Aug 23, 2023

What problem are you trying to solve?

Some plugins have many functional test assertions using an overly verbose idiom for triggering a build of a test project, waiting for the build to complete, and then checking the result of the build. There are simpler idioms available in the JenkinsRule test utility, and we can also apply centralized improvements to make this workflow more reliable (removing nondeterministic aspects).

What precondition(s) should be checked before applying this recipe?

Any Jenkins plugins using JenkinsRule (a default test dependency), whether explicitly as a @Rule, or as a parameter passed into a method when the @Rule is actually something else (RestartableJenkinsRule, JenkinsSessionRule, RealJenkinsRule).

Describe the situation before applying the recipe

Some idiom variants:

rule.assertBuildStatusSuccess(project1.scheduleBuild2(0).get());
FreeStyleBuild build2 = project2.scheduleBuild2(0, new Cause.UserIdCause()).get();
rule.assertBuildStatus(Result.FAILURE, build2);

Describe the situation after applying the recipe

The corresponding simpler versions:

rule.buildAndAssertSuccess(project1);
FreeStyleBuild build2 = rule.buildAndAssertStatus(Result.FAILURE, project2);

Have you considered any alternatives or workarounds?

Regexp search and replace?!

Any additional context

N/A

Are you interested in contributing this recipe to OpenRewrite?

TBD

@timtebeek timtebeek added the recipe Requests for new automated code changes label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requests for new automated code changes
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants