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

  • Home
  • SEARCH
  • 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 3229670
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:50:15+00:00 2026-05-17T16:50:15+00:00

I want to make a unit test suite of the same object with same

  • 0

I want to make a unit test suite of the same object with same variable but different values. However if the object get the same name (created by this.setName("testlaunch"); (we must have the name of a method tested by JUnit), it runs only one test.

If i don’t write this.setName("testlaunch"); it complains saying junit.framework.AssertionFailedError: TestCase.fName cannot be null.
I don’t know what to do…

public class LanceurRegleGestion extends TestSuite
{
    public static Test suite()
    {
        Class maClasse = null;
        TestSuite suite = new TestSuite();

        String filtre = ".*.xml";
        // on compile le pattern pour l'expression réguliere
        Pattern p = Pattern.compile(filtre);
        String path = "D:/Documents/workspace/Solipsisme/src/ReglesGestion/XML/";
        // on liste les fichiers du repertoire
        String [] u = new File(path).list();
        // on parcours la liste de fichier
        System.out.println("Initialisation");


        for (int i=0; i

et le code de l'objet serialisé

public class Application extends TestCase { private String nomappli; private String id2_1; private String id3_1; private String id4_1; private String id2_2; private String id3_2; private String id4_2; private String id5_2; private String id6_2; private String id7_2; private String id8_2; private String id9_2; private String id2_3; private String id3_3; private String id4_3; private String id2_4; private String id3_4; private String id4_4; private String id2_5; private String id3_5; private String id4_5; private String id5_5; private String id6_5; private String id7_5; private static Selenium selenium; public Application(String nomappli,String id2_1,String id3_1,String id4_1,String id2_2,String id3_2,String id4_2,String id5_2,String id6_2,String id7_2,String id8_2,String id9_2,String id2_3,String id3_3,String id4_3,String id2_4,String id3_4,String id4_4,String id2_5, String id3_5,String id4_5,String id5_5,String id6_5,String id7_5) { this.setName("testlaunch"); this.nomappli = nomappli; this.id2_1 = id2_1; this.id3_1 = id3_1; this.id4_1 = id4_1; this.id2_2 = id2_2; this.id3_2 = id3_2; this.id4_2 = id4_2; this.id5_2 = id5_2; this.id6_2 = id6_2; this.id7_2 = id7_2; this.id8_2 = id8_2; this.id9_2 = id9_2; this.id2_3 = id2_3; this.id3_3 = id3_3; this.id4_3 = id4_3; this.id2_4 = id2_4; this.id3_4 = id3_4; this.id4_4 = id4_4; this.id2_5 = id2_5; this.id3_5 = id3_5; this.id4_5 = id4_5; this.id5_5 = id5_5; this.id6_5 = id6_5; this.id7_5 = id7_5; } public Application(){ } public String toString() { return getNomappli(); } public void setNomappli(String nomappli) { this.nomappli = nomappli; } public String getNomappli() { return this.nomappli; } public void setId2_1(String id2_1) { this.id2_1 = id2_1; } public String getId2_1() { return this.id2_1; } public void setId3_1(String id3_1) { this.id3_1 = id3_1; } public String getId3_1() { return this.id3_1; } public void setId4_1(String id4_1) { this.id4_1 = id4_1; } public String getId4_1() { return this.id4_1; } public void setId2_2(String id2_2) { this.id2_2 = id2_2; } public String getId2_2() { return this.id2_2; } public void setId3_2(String id3_2) { this.id3_2 = id3_2; } public String getId3_2() { return this.id3_2; } public void setId4_2(String id4_2) { this.id4_2 = id4_2; } public String getId4_2() { return this.id4_2; } public void setId5_2(String id5_2) { this.id5_2 = id5_2; } public String getId5_2() { return this.id5_2; } public void setId6_2(String id6_2) { this.id6_2 = id6_2; } public String getId6_2() { return this.id6_2; } public void setId7_2(String id7_2) { this.id7_2 = id7_2; } public String getId7_2() { return this.id7_2; } public void setId8_2(String id8_2) { this.id8_2 = id8_2; } public String getId8_2() { return this.id8_2; } public void setId9_2(String id9_2) { this.id9_2 = id9_2; } public String getId9_2() { return this.id9_2; } public void setId2_3(String id2_3) { this.id2_3 = id2_3; } public String getId2_3() { return this.id2_3; } public void setId3_3(String id3_3) { this.id3_3 = id3_3; } public String getId3_3() { return this.id3_3; } public void setId4_3(String id4_3) { this.id4_3 = id4_3; } public String getId4_3() { return this.id4_3; } public void setId2_4(String id2_4) { this.id2_4 = id2_4; } public String getId2_4() { return this.id2_4; } public void setId3_4(String id3_4) { this.id3_4 = id3_4; } public String getId3_4() { return this.id3_4; } public void setId4_4(String id4_4) { this.id4_4 = id4_4; } public String getId4_4() { return this.id4_4; } public void setId2_5(String id2_5) { this.id2_5 = id2_5; } public String getId2_5() { return this.id2_5; } public void setId3_5( String id3_5) { this.id3_5 = id3_5; } public String getId3_5() { return this.id3_5; } public void setId4_5(String id4_5) { this.id4_5 = id4_5; } public String getId4_5() { return this.id4_5; } public void setId5_5(String id5_5) { this.id5_5 = id5_5; } public String getId5_5() { return this.id5_5; } public void setId6_5(String id6_5) { this.id6_5 = id6_5; } public String getId6_5() { return this.id6_5; } public void setId7_5(String id7_5) { this.id7_5 = id7_5; } public String getId7_5() { return this.id7_5; } public void setSelenium(Selenium selenium) { this.selenium = selenium; } public Selenium getSelenium() { return this.selenium; } public final static void login() { selenium.open("apj/ident"); selenium.type("username", "hsuzumiya-cp"); selenium.type("password", "1"); selenium.click("enterButton"); selenium.waitForPageToLoad("9999999"); } public void testlaunch() { generique(this.nomappli,this.id2_1,this.id3_1,this.id4_1,this.id2_2,this.id3_2,this.id4_2,this.id5_2,this.id6_2,this.id7_2,this.id8_2,this.id9_2,this.id2_3,this.id3_3,this.id4_3,this.id2_4,this.id3_4,this.id4_4,this.id2_5,this.id3_5,this.id4_5,this.id5_5,this.id6_5,this.id7_5); } public void setUp() throws Exception { System.out.println("Initialisation"); selenium = new DefaultSelenium("127.0.0.1",4444,"*iexplore", "http://hsuzumiya/"); selenium.start(); selenium.setTimeout("90000"); selenium.setSpeed("500"); login(); } public void generique(String nomappli,String id2_1,String id3_1,String id4_1,String id2_2,String id3_2,String id4_2, String id5_2,String id6_2,String id7_2,String id8_2,String id9_2,String id2_3,String id3_3,String id4_3,String id2_4, String id3_4,String id4_4,String id2_5, String id3_5,String id4_5,String id5_5,String id6_5,String id7_5 ) { System.out.println(nomappli); selenium.click("valider"); selenium.waitForPageToLoad("30000"); selenium.click("validertout"); } public final void tearDown() throws Exception { System.out.println("Killing session"); selenium.stop(); } }
  • 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-17T16:50:16+00:00Added an answer on May 17, 2026 at 4:50 pm

    Being new to junit, I stumbled upon this question hoping to solve a problem I had getting the same message. Through further research, I found that it is necessary to pass the name of the test function you want to invoke through addTest to the constructor of the test case class. A simple (and useless, other than illustration) example follows:

    JunitTestCases.java

    import junit.framework.TestCase;
    public class JunitTestCases extends TestCase {
        public JunitTestCases(String fnName) {
            super(fnName);
        }
        public void testA() {
            assertTrue("assertTrue failed", true);
        }
    }
    

    JunitTestSuite.java:

    import junit.framework.*;
    
    public class JunitTestSuite {
        public static Test suite() {
            TestSuite suite = new TestSuite();
            suite.addTest(new JunitTestCases("testA"));
        return suite;
        }
    
        public static void main(String[] args) {
            junit.textui.TestRunner.run(suite());
        }
    }
    

    When I compiled with:

    javac -cp .:path/to/junit-X.X.X.jar JunitTestSuite.java

    and ran with

    java -cp .:path/to/junit-X.X.X.jar JunitTestSuite

    this worked with no errors, with junit giving me an OK message.

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

Sidebar

Related Questions

I'm writing a unit test for a Wicket WebPage. I want to fire up
I have a class that I want to use in many test cases: require
So I have this reaaaally long method that I want to test. I could
I have a unit test that uses the hamcrest library (1.2). It's important that
I have just coded the below regular expression. I have a mini rich text
We are using StructureMap as our Dependency Injection (DI) framework while we are creating
I've got some code that performs some legacy 'database' operation and then processes the
I am fiddling around trying to install an application via ClickOnce - with certain
I'm using Reactive Extensions for .NET (Rx) to expose events as IObservable<T> . I

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.