The full code progress I mentioned is here:
http://hastebin.com/paruraheze.xml

Thanks,
Eduard

On Wed, Jan 7, 2015 at 6:24 PM, Eduard Moraru <[email protected]> wrote:

> Hi,
>
> I`ve tried a different approach after finding this method:
>
> http://javadoc.jenkins-ci.org/hudson/tasks/test/AbstractTestResultAction.html#setDescription%28hudson.tasks.test.TestObject,%20java.lang.String%29
>
> So it seems that TestObjects are not persisted so I would have to use that
> protected method instead. AFAIK that works in Groovy, even if the method is
> persisted, so I tried the following, going from bottom-up this time:
>
> testResultAction = failedTest.getParentAction()
> testResult = testResultAction.getResult()
>
> testResultAction.setDescription(failedTest, "Some description");
> manager.build.save();
>
> However, no luck!
>
> For some reason, even if the setDescription menthod is supposed to set the
> description in the list of descriptions of the SurefireReport action
> (subclass of TestResultAction), the save method is not persisting the
> description in the build.xml file.
>
> From setting the description manually, I can confirm that that is the
> place where it is supposed to be saved and that the SurefireReport action
> is the right one to use. Maybe I am not calling save() on the right
> instance?
>
> I would really appreciate some help on this one since I am so close to
> finishing it and I have spent a lot of time going back and forward with it.
>
> This is the full code of the progress I`ve done with my script. Just need
> to save the failed test's description...
>
> Thanks,
> Eduard
>
> P.S.: I have stopped pursuing the setResults() method since I am almost
> sure that even if it saves stuff, it saves it to junitResult.xml and that
> does not hold descriptions. Again, from manual testing, it seems that
> build.xml stores the test descriptions inside the SurefireReport action.
>
>
> On Wed, Jan 7, 2015 at 1:30 PM, Eduard Moraru <[email protected]>
> wrote:
>
>> Hi,
>>
>> It seems to make sense what you are saying, however, I can not get to an
>> instance of TestResultAction.
>>
>> I have tried many things and did a lot of printing to see what I am
>> working with. Here is what I get for the following:
>>
>> manager.build.getClass() --> class hudson.maven.MavenModuleSetBuild
>> manager.build.testResultAction.getClass() --> class
>> hudson.maven.reporters.SurefireAggregatedReport
>> manager.build.aggregatedTestResultAction.getClass() --> class
>> hudson.maven.reporters.SurefireAggregatedReport
>> manager.build.getAction(hudson.tasks.junit.TestResultAction.class) -->
>> null
>> manager.build.getAction(hudson.tasks.test.AbstractTestResultAction.class)
>> --> hudson.maven.reporters.SurefireAggregatedReport@bb1453
>> manager.build.testResultAction.result.getClass() --> class
>> hudson.tasks.test.AggregatedTestResultAction$1 (assuming this one is
>> ChildReport)
>> manager.build.testResultAction.getResult().getClass() --> class
>> hudson.tasks.test.AggregatedTestResultAction$1 (assuming this one is
>> ChildReport)
>>
>> I`m a bit stuck at this point. Any idea?
>>
>> Thanks,
>> Eduard
>>
>> On Wed, Jan 7, 2015 at 1:19 AM, Daniel Beck <[email protected]> wrote:
>>
>>> Test results are stored in weak references to be discarded in case
>>> memory is required for something else. Builds themselves aren't kept in
>>> memory either. And the code you have does not persist test results to disk.
>>>
>>>
>>> https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/junit/TestResultAction.java#L123...L142
>>>
>>> Something like the following should work (untested):
>>>
>>>    def result = manager.build.testResultAction.result
>>>    failedTests = result.getFailedTests()
>>>    // changes to tests in the result here
>>>    manager.build.testResultAction.setResult(result, manager.listener)
>>>
>>> You can check whether it works by looking at the junitResult.xml file's
>>> modification date and contents and/or restarting Jenkins.
>>>
>>> On 06.01.2015, at 23:46, Eduard Moraru <[email protected]> wrote:
>>>
>>> > Hi,
>>> >
>>> > I have recently written a pretty nice along the lines of this blogpost
>>> http://brknthmb.com/post/76243353208/jenkins-adding-selenium-screenshots-to-test
>>> (with some modifications).
>>> >
>>> > It is working great... however only for about 1 hour. After that, any
>>> descriptions set by the postbuild script (e.g. someCaseResult.description =
>>> "Some Description") on a failed test vanish like they were never there.
>>> When I come back later I only see the option "Add description" instead of
>>> the previously set description.
>>> >
>>> > There is even an example in the plugin's documentation (
>>> https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin#GroovyPostbuildPlugin-Example9%28thankstoKenBertelson%29
>>> ) about doing it this way and I wonder if anyone else has encountered this
>>> problem and how I may get around it.
>>> >
>>> > I am now trying to see if this replicates with a description that I
>>> set manually on a failed test result, I will come back tomorrow with the
>>> results of this test.
>>> >
>>> > Using Jenkins ver. 1.565.3 LTS.
>>> >
>>> > Thanks,
>>> > Eduard
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" 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-users/CADGDyYJvfjduApWJUZA2z-omksMbTX8sTHiJM_7kex9K2buWbQ%40mail.gmail.com
>>> .
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" 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-users/ACC7C44A-FB0F-4F60-89C7-C16F36DD9D2C%40beckweb.net
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" 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-users/CADGDyYKPyX9X4dJRui6OL5b8MdVwj9gcMH4PZpJKhmRny9LErg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to