• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

how to run awtui ?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I am new to JUnit. I am able to run the test code successfully through the textui but i am unable to run the test code using awtui or swingui . Please somebody suggest me how to use awtui or swingui .

Below is my java class which needs testing

public class Math
{
static public int add(int a, int b)
{
return a + b;
}
}

Below is my test class

import junit.framework.*;

public class TestMath extends TestCase
{
public void testAdd()
{
int num1 = 3;
int num2 = 2;
int total = 5;
int sum = 0;
sum = Math.add(num1, num2);
assertEquals("Problem with addition",sum, total);
}
}

I have downloaded the JUnit from the internet and kept it on the classpath.

Now i have used the following option

prompt> java junit.textui.TestRunner TestMath

its working

but the following things are not working why ???

prompt> java junit.awtui.TestRunner TestMath
prompt> java junit.swingui.TestRunner TestMath

The error it showing is

Exception is thread main java.lang.NoClassDefFoundError: junit/awtui/TestRunner

Exception is thread main java.lang.NoClassDefFoundError: junit/swingui/TestRunner

Please somebody help me in this . ............

regards

Johnson
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the value of CLASSPATH? Apparently the JVM doesn't think that JUnit is part of it.

I'd advise not to use the CLASSPATH environment variable, but instead to specify the classpath explicitly via "-classpath" switch.
 
author & internet detective
Posts: 41125
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johnson,
Is JUnit 4 in your classpath? JUnit 4 only supports the text runner and not the awt/swing ones.
 
Johnson David
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne Boyarsky,

Thanks for your answer. As you said i have JUnit 4.1 on the classpath, which is not supporting awtui and swingui.

It will be nice if you can tell me the version which supports it.

cheers,

Johnson
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only earlier versions (3.x) come with the other runners.

There is now such a good IDE support for JUnit out there that the JUnit developers thought of it as waste to still put energy into maintaining the graphical standalone runners.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the record, I think that discontinuing the support for the JUnit GUI
was a bad idea. In particular, it is sorely missed in educational
settings where one tries to teach programming, not the IDE of the day.
Besides, the IDE support is rather spotty, in my opinion.

Cheers,
Glenn
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic