Hey guys,

I'm having a wield problem on the executing sequence in afterTest method of
Test task.

I have three tasks, two Test task runs the same Geb+junit test, the other is
a action simply print a message.

They are follows:

task testA(type: Test ) {
        testA.ignoreFailures = true
        testA.afterTest{ TestDescriptor descriptor, TestResult result ->
                if 
(TestResult.ResultType.FAILURE.equals(result.getResultType())) {
                        println "A1"
                        if(test.getName()!="classMethod"){
                                println "A2"
                                sleep 5000
                                testB.execute()
                                println "A3:return from testB"
                                return
                        }
                }else {
                        println "A4"
                        return
                }
        }
}

task testB(type: Test ) {
        testB.ignoreFailures = true
        testB.afterTest{ TestDescriptor descriptor, TestResult result ->
                if 
(TestResult.ResultType.FAILURE.equals(result.getResultType())) {
                        println "B1"
                        if(test.getName()!="classMethod"){
                                println "B2"
                                sleep 5000
                                notATest.execute()
                                println "B3: return from notATest"
                                return
                        }
                }else {
                        println "B4"
                        return
                }
        }
}

task notATest() << {    
                println "do notATest "
}


So when I run testA, it starts with running the test, and when the test
fails, 

it prints:
"A1"
"A2"
then sleep for 5 seconds and continue with running testB, the test fail
again, and then it prints:
"B1"
"B2"
then sleep for 5 seconds and goes into task notATest, and print:
"do notATest"
then it returns testB and prints:
"B3: return from notATest"

So far so good! However, it keep working to print:
"B1"
"B2"
"B3"
This now is very wield, it goes back to the start of testB's testListener
and print those message again! And it does not print "do notATest", which
means it only print message in testB, but not go to further method call
again!?

The rest of running is similarly wield:
goes back to caller testA and print:
"A3:return from testB"
"A1"
"A2"
sleep 5 sec, but not goes into testB again, keep print:
"A3:return from testB"
and then end.

What could be the reason of this?

I know the geb junit test may have two test results, one is called
"classMethod" and so that I have if condition to ignore it.

Sorry for such a long post, I find no way to explain it both clearly and
shortly, but really hope to get some idea on what's happening here.

Thanks a lot in advance.

/wazh


--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Calls-in-testListener-does-not-return-properly-tp4513615p4513615.html
Sent from the gradle-user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to