【发布时间】:2011-03-26 04:32:15
【问题描述】:
我想为具有相同变量但值不同的同一对象制作一个单元测试套件。但是,如果对象具有相同的名称(由this.setName("testlaunch"); 创建(我们必须具有由 JUnit 测试的方法的名称),则它只运行一个测试。
如果我不写this.setName("testlaunch");,它会抱怨说junit.framework.AssertionFailedError: TestCase.fName cannot be null。
我不知道该怎么办...
et le code de l'objet serialisé
公共类应用程序扩展TestCase { 私有字符串 nomappli; 私有字符串 id2_1; 私有字符串 id3_1; 私有字符串 id4_1; 私人字符串 id2_2; 私有字符串 id3_2; 私有字符串 id4_2; 私有字符串 id5_2; 私有字符串 id6_2; 私有字符串 id7_2; 私有字符串 id8_2; 私人字符串 id9_2; 私有字符串 id2_3; 私有字符串 id3_3; 私有字符串 id4_3; 私有字符串 id2_4; 私有字符串 id3_4; 私有字符串 id4_4; 私有字符串 id2_5; 私有字符串 id3_5; 私有字符串 id4_5; 私有字符串 id5_5; 私有字符串 id6_5; 私有字符串 id7_5; 私有静态硒硒; 公共应用程序(字符串 nomappli,字符串 id2_1,字符串 id3_1,字符串 id4_1,字符串 id2_2,字符串 id3_2,字符串 id4_2,字符串 id5_2,字符串 id6_2,字符串 id7_2,字符串 id8_2,字符串 id9_2,字符串 id2_3,字符串 id3_3,字符串 id4_3,字符串 id2_4 ,字符串 id3_4,字符串 id4_4,字符串 id2_5,字符串 id3_5,字符串 id4_5,字符串 id5_5,字符串 id6_5,字符串 id7_5) { this.setName("testlaunch"); this.nomappli = nomappli; 这个.id2_1 = id2_1; 这.id3_1 = id3_1; this.id4_1 = id4_1; 这.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; 这.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; } 公共应用程序(){ } 公共字符串 toString() { 返回 getNomappli(); } 公共无效 setNomappli(字符串 nomappli) { this.nomappli = nomappli; } 公共字符串 getNomappli() { 返回这个.nomappli; } 公共无效 setId2_1(字符串 id2_1) { 这个.id2_1 = id2_1; } 公共字符串 getId2_1() { 返回 this.id2_1; } 公共无效 setId3_1(字符串 id3_1) { 这.id3_1 = id3_1; } 公共字符串 getId3_1() { 返回 this.id3_1; } 公共无效 setId4_1(字符串 id4_1) { this.id4_1 = id4_1; } 公共字符串 getId4_1() { 返回 this.id4_1; } 公共无效 setId2_2(字符串 id2_2) { 这.id2_2 = id2_2; } 公共字符串 getId2_2() { 返回 this.id2_2; } 公共无效 setId3_2(字符串 id3_2) { this.id3_2 = id3_2; } 公共字符串 getId3_2() { 返回 this.id3_2; } 公共无效 setId4_2(字符串 id4_2) { this.id4_2 = id4_2; } 公共字符串 getId4_2() { 返回 this.id4_2; } 公共无效 setId5_2(字符串 id5_2) { this.id5_2 = id5_2; } 公共字符串 getId5_2() { 返回 this.id5_2; } 公共无效 setId6_2(字符串 id6_2) { this.id6_2 = id6_2; } 公共字符串 getId6_2() { 返回 this.id6_2; } 公共无效 setId7_2(字符串 id7_2) { this.id7_2 = id7_2; } 公共字符串 getId7_2() { 返回 this.id7_2; } 公共无效 setId8_2(字符串 id8_2) { this.id8_2 = id8_2; } 公共字符串 getId8_2() { 返回 this.id8_2; } 公共无效 setId9_2(字符串 id9_2) { this.id9_2 = id9_2; } 公共字符串 getId9_2() { 返回 this.id9_2; } 公共无效 setId2_3(字符串 id2_3) { this.id2_3 = id2_3; } 公共字符串 getId2_3() { 返回 this.id2_3; } 公共无效 setId3_3(字符串 id3_3) { this.id3_3 = id3_3; } 公共字符串 getId3_3() { 返回 this.id3_3; } 公共无效 setId4_3(字符串 id4_3) { this.id4_3 = id4_3; } 公共字符串 getId4_3() { 返回 this.id4_3; } 公共无效 setId2_4(字符串 id2_4) { this.id2_4 = id2_4; } 公共字符串 getId2_4() { 返回 this.id2_4; } 公共无效 setId3_4(字符串 id3_4) { this.id3_4 = id3_4; } 公共字符串 getId3_4() { 返回 this.id3_4; } 公共无效 setId4_4(字符串 id4_4) { this.id4_4 = id4_4; } 公共字符串 getId4_4() { 返回 this.id4_4; } 公共无效 setId2_5(字符串 id2_5) { 这.id2_5 = id2_5; } 公共字符串 getId2_5() { 返回 this.id2_5; } 公共无效 setId3_5(字符串 id3_5) { this.id3_5 = id3_5; } 公共字符串 getId3_5() { 返回 this.id3_5; } 公共无效 setId4_5(字符串 id4_5) { this.id4_5 = id4_5; } 公共字符串 getId4_5() { 返回 this.id4_5; } 公共无效 setId5_5(字符串 id5_5) { this.id5_5 = id5_5; } 公共字符串 getId5_5() { 返回 this.id5_5; } 公共无效 setId6_5(字符串 id6_5) { this.id6_5 = id6_5; } 公共字符串 getId6_5() { 返回 this.id6_5; } 公共无效 setId7_5(字符串 id7_5) { this.id7_5 = id7_5; } 公共字符串 getId7_5() { 返回 this.id7_5; } 公共无效集硒(硒硒) { this.selenium = 硒; } 公共硒 getSelenium() { 返回 this.selenium; } 公共最终静态无效登录() { selenium.open("apj/ident"); selenium.type("用户名", "hsuzumiya-cp"); selenium.type("密码", "1"); selenium.click("enterButton"); selenium.waitForPageToLoad("9999999"); } 公共无效测试启动() { 通用(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); } 公共 void setUp() 抛出异常 { System.out.println("初始化"); selenium = new DefaultSelenium("127.0.0.1",4444,"*iexplore", "http://hsuzumiya/"); selenium.start(); selenium.setTimeout("90000"); selenium.setSpeed("500"); 登录(); } 公共无效通用(字符串 nomappli,字符串 id2_1,字符串 id3_1,字符串 id4_1,字符串 id2_2,字符串 id3_2,字符串 id4_2, 字符串 id5_2,字符串 id6_2,字符串 id7_2,字符串 id8_2,字符串 id9_2,字符串 id2_3,字符串 id3_3,字符串 id4_3,字符串 id2_4, 字符串 id3_4、字符串 id4_4、字符串 id2_5、字符串 id3_5、字符串 id4_5、字符串 id5_5、字符串 id6_5、字符串 id7_5 ) { System.out.println(nomappli); selenium.click("验证器"); selenium.waitForPageToLoad("30000"); selenium.click("validertout"); } public final void tearDown() 抛出异常 { System.out.println("杀死会话"); 硒。停止(); } }【问题讨论】:
-
很难理解您对问题的描述。您可以发布失败的断言的堆栈跟踪吗?
标签: java serialization object junit