That shouldn't be the case if you use JenkinsRule, actually create the
project, and run a quick echo pipeline a few times.
I know from working on the java 11 stuff, that mockito has trouble mocking
functions that are final, it'll silently not do so. Its going to save you a
ton of headaches to use JenkinsRule.
@Rule
public JenkinsRule j = new JenkinsRule()
p = j.createFreeStyleProject("name");
jenkins.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0)); // build 1
jenkins.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0)); // build 2
jenkins.assertBuildStatus(Result.SUCCESS, p.scheduleBuild2(0)); // build 3
but i see you are messing with dates, so that might be trickier, i'm not
sure.
You can try subclassing FreeStyleProject, and overriding the function to
return the value you want.
If that works fine, then its how the function matching/overriding works in
mockito, if it doesn't work, then its the weird final/static stuff that
mockito has trouble with. You might need to also use powermock and prepare
for test.
On Mon, Jul 8, 2019 at 12:40 PM 'Benjamin Beggs' via Jenkins Developers <
[email protected]> wrote:
> The issue here is with my build history instantiation. All build retrieve
> calls return null regardless of method (getFirstBuild, getLastBuild,
> getBuildByNumber, etc).
>
> On Monday, July 8, 2019 at 3:24:47 PM UTC-4, Benjamin Beggs wrote:
>>
>> I will investigate this further, thanks for pointing this implementation
>> out to me.
>>
>> On Monday, July 8, 2019 at 1:52:40 PM UTC-4, Jesse Glick wrote:
>>>
>>> On Mon, Jul 8, 2019 at 1:39 PM 'Benjamin Beggs' via Jenkins Developers
>>> <[email protected]> wrote:
>>> > Do you have an example of a similar implementation for unit testing
>>> using jenkinsrule? I may try just porting the tests over to this.
>>>
>>> I would definitely advise using `JenkinsRule` over mocking frameworks.
>>> Slower, but much more realistic (and much more likely to continue
>>> running after internal refactorings). Example:
>>>
>>>
>>> https://github.com/jenkinsci/jenkins/blob/a6f5b2b1288d15cd2ea5c2fd9b8916e6397bf795/test/src/test/java/hudson/tasks/LogRotatorTest.java#L67-L82
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/610d3de0-c377-4c4c-bd2d-db00c84b6f41%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/610d3de0-c377-4c4c-bd2d-db00c84b6f41%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_DusEatx84S_rYmUYw3QkC7FWGEy2X75dZZmOC9BNEyZTiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.