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

SQ Plugin: Replace usages of deprecated Build.setProfile in the integration tests #3102

Closed
costin-zaharia-sonarsource opened this issue Feb 6, 2020 · 1 comment · Fixed by #9563
Assignees
Labels
Area: SQ Plugin Java plugin related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: Tooling Tools make us productive.
Milestone

Comments

@costin-zaharia-sonarsource
Copy link
Member

Build.setProfile method is used multiple times in the integration tests but it has been deprecated and currently, calling it, doesn't have the expected result.

As an example, if I delete the call from no_coverage_on_tests the test remains green.

We have to remove the calls, replace them with provisionProject() and associateProjectToQualityProfile() where needed and see if the tests are still valid since removing a method call still keeps the test successful.

@costin-zaharia-sonarsource costin-zaharia-sonarsource added Area: C# C# rules related issues. Type: Tooling Tools make us productive. Area: VB.NET VB.NET rules related issues. Type: Improvement labels Feb 6, 2020
@pavel-mikula-sonarsource pavel-mikula-sonarsource added the Area: SQ Plugin Java plugin related issues. label Jul 9, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 9.31 milestone Jul 23, 2024
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title Replace usages of deprecated Build.setProfile in the integration tests SQ Plugin: Replace usages of deprecated Build.setProfile in the integration tests Jul 26, 2024
@sebastien-marichal
Copy link
Contributor

sebastien-marichal commented Jul 26, 2024

From #8389


It is now used only in Tests.analyzeProject.

It is not as simple as replacing the call, associateProjectToQualityProfile requires the project to already exist as it calls the api/qualityprofiles/add_project endpoint which assumes that the project exists.

One approach could be:

  public static BuildResult analyzeProject(String projectKey, Path temp, String projectDir, @Nullable String profileKey, String... keyValues) throws IOException {
    Path projectFullPath = TestUtils.projectDir(temp, projectDir);

    if (profileKey != null) {
      ORCHESTRATOR.getServer().provisionProject(projectKey, projectKey); // Create the project
      ORCHESTRATOR.getServer().associateProjectToQualityProfile(projectKey, "cs", profileKey); // Bind the profile to it
    }

    ScannerForMSBuild beginStep = TestUtils.createBeginStep(projectKey, projectFullPath)
      .setProperties(keyValues);

    ORCHESTRATOR.executeBuild(beginStep);
    TestUtils.runBuild(projectFullPath);
    return ORCHESTRATOR.executeBuild(TestUtils.createEndStep(projectFullPath));
  }

The same goes for the VBNET version.
Usage outside the Tests class should be checked as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: SQ Plugin Java plugin related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: Tooling Tools make us productive.
Projects
None yet
6 participants