Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-69756

Improve node label parameter plugin automated test coverage

      Increase automated test coverage

      Automated test coverage of the node and label parameter plugin is lower that is desired. Improve the automated test coverage by submitting pull requests with new automated tests.

      Review current coverage

      Review the current test coverage with the commands:

      Linux

      $ mvn -P enable-jacoco clean install jacoco:report
      $ xdg-open target/site/jacoco/index.html
      

      Windows

      C:\Users\Yourname > mvn -P enable-jacoco clean install jacoco:report
      C:\Users\Yourname > start target\site\jacoco\index.html
      

      More information is in the "code coverage" section of the contributing guide.

      Create a new test for a class that is not well covered

      Most integrated development environments have tools that will create a test stub that is a good beginning. Apache Netbeans has "Create / Update tests" . JetBrains IntelliJ has "Create tests". Visual Studio Code has the "Extension Pack for Java".

      Use the IDE or your own coding to create a test for one of the classes that is not well covered by tests.

      Keep the test small so that the pull request is easy to review.

          [JENKINS-69756] Improve node label parameter plugin automated test coverage

          Udit added a comment -

          Hi shamly 
          Are you still working on this?
          If you currently don't have time for this issue, I can start working on this

          Udit added a comment - Hi shamly   Are you still working on this? If you currently don't have time for this issue, I can start working on this

          Mark Waite added a comment -

          udit_damare I've removed the assignment of shamly  since there has been no progress on it since shamly  self-assigned it several months ago.

          I've found that assigning a beginner friendly issue to someone is rarely successful.  Interest is expressed, but then there is no further progress.  Others see that it is assigned and hesitate to help.  This specific issue has many, many ways that multiple contributors can help.  The red classes shown in the coverage report (lines and classes tabs) all would benefit from more automated tests.

          Mark Waite added a comment - udit_damare I've removed the assignment of shamly   since there has been no progress on it since shamly   self-assigned it several months ago. I've found that assigning a beginner friendly issue to someone is rarely successful.  Interest is expressed, but then there is no further progress.  Others see that it is assigned and hesitate to help.  This specific issue has many, many ways that multiple contributors can help.  The red classes shown in the coverage report (lines and classes tabs) all would benefit from more automated tests.

          Udit added a comment -

          Okay markewaite 
          I'll check the coverage reports

          Udit added a comment - Okay markewaite   I'll check the coverage reports

          Manish added a comment -

          Is it okay if I assign this issue to myself? I want to try this one

          Manish added a comment - Is it okay if I assign this issue to myself? I want to try this one

          Mark Waite added a comment -

          manish4044 you are welcome to work on this issue.

          We don't assign issues to new contributors because that causes other new contributors to mistakenly assume that they are not allowed to help with the issue. There is plenty of room for multiple concurrent contributors to submit new tests to better test the plugin. We don't need to assign to an individual. It is enough to state in the comment that you'd like to contribute, then start a pull request that adds a test.

          Mark Waite added a comment - manish4044 you are welcome to work on this issue. We don't assign issues to new contributors because that causes other new contributors to mistakenly assume that they are not allowed to help with the issue. There is plenty of room for multiple concurrent contributors to submit new tests to better test the plugin. We don't need to assign to an individual. It is enough to state in the comment that you'd like to contribute, then start a pull request that adds a test.

          Nikhil added a comment -

          Hi markewaite ,

          I've added some changes to improve the code coverage in this PR: https://github.com/jenkinsci/nodelabelparameter-plugin/pull/362

          Test report screenshots are added in the description.

          Please do have a look and let me know for any changes.

           

          Nikhil added a comment - Hi markewaite , I've added some changes to improve the code coverage in this PR: https://github.com/jenkinsci/nodelabelparameter-plugin/pull/362 Test report screenshots are added in the description. Please do have a look and let me know for any changes.  

          Yash added a comment -

          Hey markewaite I have been trying to create Automated tests for this plugin, particularly right now I am trying to create a JUnit 5 test for AllNodesBuildParameterFactory.java .
          I had to ask to confirm how do you want them to be created should I just use Jenkins freestyle project  / Jenkins rule or should I also use Mock objects and Mockito framework.

          Or do you want them to be written in a certain way please specify as much as possible and anything else you might consider telling me that I missed but would help me.

          Yash added a comment - Hey markewaite I have been trying to create Automated tests for this plugin, particularly right now I am trying to create a JUnit 5 test for AllNodesBuildParameterFactory.java . I had to ask to confirm how do you want them to be created should I just use Jenkins freestyle project  / Jenkins rule or should I also use Mock objects and Mockito framework. Or do you want them to be written in a certain way please specify as much as possible and anything else you might consider telling me that I missed but would help me.

          Mark Waite added a comment -

          yash_21 I generally prefer JenkinsRule tests with either Pipeline jobs or freestyle jobs rather than mock objects.

          I generally prefer JUnit 4 tests rather than JUnit 5 tests because Jenkins test harness does not yet have full support for JUnit 5.

          I generally prefer hamcrest assertions because I find them easier to read when diagnosing a failure.

          Mark Waite added a comment - yash_21 I generally prefer JenkinsRule tests with either Pipeline jobs or freestyle jobs rather than mock objects. I generally prefer JUnit 4 tests rather than JUnit 5 tests because Jenkins test harness does not yet have full support for JUnit 5. I generally prefer hamcrest assertions because I find them easier to read when diagnosing a failure.

          Yash added a comment -

          Sure thanks for your guidance, I will try to create the tests by myself it might take some time because this is my first time writing an entire test class from scratch.

          Yash added a comment - Sure thanks for your guidance, I will try to create the tests by myself it might take some time because this is my first time writing an entire test class from scratch.

          Mark Waite added a comment -

          Most integrated development environments offer a test generator that will create the commons parts of a JUnit test. You might check for that in your preferred IDE

          Mark Waite added a comment - Most integrated development environments offer a test generator that will create the commons parts of a JUnit test. You might check for that in your preferred IDE

            Unassigned Unassigned
            markewaite Mark Waite
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: