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 1082393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:17:26+00:00 2026-05-16T22:17:26+00:00

I’m trying to write Junit4 test cases for my Groovy code. The Junit 4

  • 0

I’m trying to write Junit4 test cases for my Groovy code. The Junit 4 test case works fine inside my Eclipse IDE which is SpringSource Tool Suite. I can’t get a test running to run the all of the test cases, however.

Here is my current attempt at a test runner. It’s pretty much taken directly from the Groovy website itself:

import groovy.util.GroovyTestSuite;
import org.codehaus.groovy.runtime.ScriptTestAdapter
import junit.framework.*;

class allTests {

static Test suite() {
  def gsuite = new GroovyTestSuite()
  gsuite.addTest(new ScriptTestAdapter(gsuite.compile("test/GSieveTest.groovy"), [] as String[]))
  return gsuite
}

}

junit.textui.TestRunner.run(allTests.suite())

Results in:

org.codehaus.groovy.runtime.InvokerInvocationException:
    org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack:
    No signature of method: GSieveTest.main() is applicable for argument types: () values: []

What’s wrong? Oh, here is the GSieveTest.groovy. I runs fine using “Run As Junit test…”

import static org.junit.Assert.assertEquals;
import org.junit.Test;

class GSieveTest {
@Test
public void Primes1To10() {
    def sieve = (0..10).toList()
    GSieve.filter(sieve); // [1,2,3,5,7]
    assertEquals("Count of primes in 1..10 not correct", 5, (sieve.findAll {it -> it != 0}).size());        
}
@Test
public void FiftyNineIsPrime() {
    def sieve = (0..60).toList()
    GSieve.filter(sieve);
    assertEquals("59 must be a prime", 59, sieve[59]);
}
@Test
public void Primes1To100() {
    def sieve = (0..100).toList()
    GSieve.filter(sieve);
    def list = sieve.findAll {it -> it != 0}
    def primes = [1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    println list
    println primes
    assertEquals(true, list == primes)
}

} 
  • 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-05-16T22:17:27+00:00Added an answer on May 16, 2026 at 10:17 pm

    Now I got it — Groovy doesn’t have a test runner for JUnit4 tests. Here is the extent of JUnit4 support:
    http://groovy.codehaus.org/Using+JUnit+4+with+Groovy

    What the script test adapter (ScriptTestAdapter) allows you to do is run groovy scripts that are NOT JUnit tests. Here’s an example:

    -----ScriptTest1.groovy--------
    import static org.junit.Assert.assertEquals;
    def sieve = (0..10).toList()
    GSieve.filter(sieve); // [1,2,3,5,7]
    assertEquals("Count of primes in 1..10 not correct", 5, (sieve.findAll {it -> it != 0}).size());
    -----end of ScriptTest1--------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.