Forum Discussion

TomK's avatar
TomK
Contributor
16 years ago

Unit testing via soapUI and Groovy

I tried to run the following groovy Unit Test script in soapUI:

import groovy.util.GroovyTestCase

class MyTest extends GroovyTestCase {
    void testSomething() {
        assert 1 == 1
        assert 2 + 2 == 4 : "We're in trouble, arithmetic is broken"
    }
}

And I got the following casting error:
Fri Jun 13 16:26:57 BST 2008:ERROR:groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class MyTest. Reason: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.apache.log4j.Logger@1560b81' with class 'org.apache.log4j.Logger' to class 'java.util.logging.Logger'

Is this a bug or did I do something wrong with the script?

Thanks,

Tom

4 Replies

  • TomK's avatar
    TomK
    Contributor
    I think I managed to narrow it down to the extends instruction.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    exactly where are you entering this script? You probably don't need to wrap the assertions in a method, just enter

    assert 1 == 1
    assert 2 + 2 == 4 : "We're in trouble, arithmetic is broken"

    regards!

    /Ole
    eviware.com
  • TomK's avatar
    TomK
    Contributor
    I was attempting to create Unit tests for the Java consumer so I have everything in one place.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    ok.. but exactly where in soapUI are you entering this script? Can you attach a screenshot?

    regards!

    /Ole
    eviware.com