[jira] [Commented] (OFBIZ-9996) Implement Groovy test in testtools

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-9996) Implement Groovy test in testtools

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-9996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264298#comment-16264298 ]

Jacques Le Roux commented on OFBIZ-9996:
----------------------------------------

Hi Nicolas,

I'm not sure it's perfectly done but it perfectly works. What I'm not sure about is what to use for classname in
{code}
<testcase classname="org.apache.ofbiz.base.util.test.UtilXmlTests" name="testUnsupportedClassConverter" time="0.013" />
<testcase classname="BaseTest" name="testDispatcher" time="0.012" />
{code}
when we will have a lot of them. Apart that I see no possible issues yet. If even it's one, because looking at runtime/logs/test-results/html/index.html all seems OK.

I tried something: in SimpleTests.groovy, I changed
{code}
    void testFalse() {
        assertNotSame 1, 0
    }
{code}
to
{code}
    void testFalse() {
        assertNotSame 1, 1
    }
{code}

I got this in console:
{code}
2017-11-23 13:51:06,462 |main                 |TestRunContainer              |I| --> testFalse(BaseTest): expected not same
2017-11-23 13:51:06,462 |main                 |TestRunContainer              |I| junit.framework.AssertionFailedError: expected not same
        at junit.framework.Assert.fail(Assert.java:57)
        at junit.framework.Assert.failSame(Assert.java:320)
        at junit.framework.Assert.assertNotSame(Assert.java:306)
        at junit.framework.Assert.assertNotSame(Assert.java:315)
        at junit.framework.TestCase.assertNotSame(TestCase.java:484)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1467)
        at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:65)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
        at BaseTest.testFalse(SimpleTests.groovy:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at junit.framework.TestCase.runTest(TestCase.java:176)
        at junit.framework.TestCase.runBare(TestCase.java:141)
        at junit.framework.TestResult$1.protect(TestResult.java:122)
        at junit.framework.TestResult.runProtected(TestResult.java:142)
        at junit.framework.TestResult.run(TestResult.java:125)
        at junit.framework.TestCase.run(TestCase.java:129)
        at junit.framework.TestSuite.runTest(TestSuite.java:255)
        at junit.framework.TestSuite.run(TestSuite.java:250)
        at junit.framework.TestSuite.runTest(TestSuite.java:255)
        at junit.framework.TestSuite.run(TestSuite.java:250)
        at org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:89)
        at org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
        at org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:73)
        at org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:219)
        at org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:71)
        at org.apache.ofbiz.base.start.Start.main(Start.java:85)

2017-11-23 13:51:06,462 |main                 |TestRunContainer              |I| [JUNIT] ------------------------------------------------------------------ [JUNIT]
org.apache.ofbiz.base.start.StartupException: Cannot start() org.apache.ofbiz.testtools.TestRunContainer (Test run was unsuccessful)
        at org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:150)
        at org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:73)
        at org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.java:219)
        at org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:71)
        at org.apache.ofbiz.base.start.Start.main(Start.java:85)
Caused by: org.apache.ofbiz.base.container.ContainerException: Test run was unsuccessful
        at org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:100)
        at org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
        ... 4 more
:ofbiz --test component=base --test suitename=basetests FAILED
:createTestReports
Trying to override old definition of datatype junitreport
[ant:junitreport] the file C:\projectsASF\ofbiz\runtime\logs\test-results\TESTS-TestSuites.xml is not a valid testsuite XML document

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ofbiz --test component=base --test suitename=basetests'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_112\bin\java.exe'' finished with non-zero exit value 1
{code}

And the HTML results are good (showing a failure):
{code}
basetests testFalse Failure expected not same

junit.framework.AssertionFailedError: expected not same
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1467)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSitte.callStatic(StaticMetaClassSite.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
at BaseTest.testFalse(SimpleTests.groovy:27)
at org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContaiiner.java:89)
at org.apache.ofbiz.base.coontainer.ContainerLoader.startLoadedContainers(ContainerLoader.java:148)
at org.apache.ofbiz.base.container.ContainerLoaderr.load(ContainerLoader.java:73)
at org.apache.ofbiz.base.start.StartupControlPanel.loadStartupLoaders(StartupControlPanel.javva:219)
at org.apache.ofbiz.bbase.start.StartupControlPanel.start(StartupControlPanel.java:71)
at org.apache.ofbiz.base.staart.Start.main(Start.java:85)
{code}

So it seems that a 1st step to be committed to me.

> Implement Groovy test in testtools
> ----------------------------------
>
>                 Key: OFBIZ-9996
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-9996
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>         Attachments: OFBIZ-9996.patch
>
>
> With the minilang deprecation and the migration to groovy, I tried to implement on the ofbiz testtools the possibility to use groovy for integration test.
> My idea is to define a new element on test-suite.xsd like this
> {code}
>         <groovy-test-suite name="simple" location="component://base/groovyScript/test/SimpleTests.groovy"/>
> {code}
> After some research and unfortunately result I found a first solution present with the linked patch.
> To test it just apply the patch and run :
> {code}
> $ ./gradlew 'ofbiz --test component=base --test suitename=basetests '
> {code}
> This execute the basetest suite with the new groovy test suite present in base/groovyScript/test/SimpleTests.groovy
> I'm sure this code may be improve if you want how don't hesitate !



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)