Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8835095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:10:53+00:00 2026-06-14T09:10:53+00:00

I’ve created a Grails plugin which adds a custom test type class (extending GrailsTestTypeSupport

  • 0

I’ve created a Grails plugin which adds a custom test type class (extending GrailsTestTypeSupport) and custom test result class (extending GrailsTestTypeResult) to support a custom test type that I run during the other phase of the test-app script. Testing this on my local machine has gone swimmingly but…

When I packaged the plugin to use in my app, the tests are blowing up on our CI server (Jenkins). Here’s the error that Jenkins is spitting out:

unable to resolve class CustomTestResult  @ line 58, column 9.
       new CustomTestResult(tests.size() - failed, failed)

It appears that I cannot simply import these classes into _Events.groovy, and the classes are not otherwise on the classpath. But I’ll be damned if I can figure out how to get them onto the classpath. Here’s what I have so far (in _Events.groovy):

import java.lang.reflect.Constructor

eventAllTestsStart = {
  if (!otherTests) otherTests = []

  loadCustomTestResult()
  otherTests << createCustomTestType()
}

private def createCustomTestType(String name = 'js', String relativeSourcePath = 'js') {
  ClassLoader parent = getClass().getClassLoader()
  GroovyClassLoader loader = new GroovyClassLoader(parent)
  Class customTestTypeClass = loader.parseClass(new File("${customTestPluginDir}/src/groovy/custom/test/CustomTestType.groovy"))
  Constructor customTestTypeConstructor = customTestTypeClass.getConstructor(String, String)
  def customTestType = customTestTypeConstructor.newInstance(name, relativeSourcePath)

  customTestType
}

private def loadCustomTestResult() {
  ClassLoader parent = getClass().getClassLoader()
  GroovyClassLoader loader = new GroovyClassLoader(parent)
  Class customTestResultClass = loader.parseClass(new File("${customTestPluginDir}/src/groovy/custom/test/CustomTestResult.groovy"))
}

Currently: CustomTestResult is only referenced from within CustomTestType. As far as I can tell, _Events.groovy is loading CustomTestType but it is failing because it then insists that CustomTestResult is not on the classpath.

Putting aside for a moment that it seems crazy that there’s this much overhead to get plugin-furnished classes onto the classpath for the test cycle to begin with… I’m not quite sure where I’ve gotten tripped up. Any help or pointers would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:10:54+00:00Added an answer on June 14, 2026 at 9:10 am

    @Ian Roberts’ answer got me pointed in roughly the right direction, and combined with the _Events.groovy script from this grails-cucumber plugin, I managed to come through with this solution:

    First, _Events.groovy became this:

    eventAllTestsStart = { if (!otherTests) otherTests = [] }
    
    eventTestPhasesStart = { phases ->
      if (!phases.contains('other')) { return }
    
      // classLoader.loadClass business per Ian Roberts:
      otherTests << classLoader.loadClass('custom.test.CustomTestType').newInstance('js', 'js')
    }
    

    Which is far more readable than where I was at the start of this thread. But: I was in roughly the same position: my ClassNotFoundException moved from being thrown in _Events.groovy to being thrown from within CustomTestType when it tried to create an instance of custom.test. CustomTestResult. So within CustomTestType, I added the following method:

    private GrailsTestTypeResult createResult(passed, failed) {
      try {
        return new customTestResult(passed, failed)
      } catch(ClassNotFoundException cnf) {
        Class customTestResult = buildBinding.classLoader.loadClass('custom.test.CustomTestResult')
        return customTestResult.newInstance(passed, failed)
      }
    }
    

    So Ian was right, inasmuch as classLoader came to the rescue — I just wound up needing its magic in two places.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.