开发者

Please let me know whether my java code is right or not?

开发者 https://www.devze.com 2023-02-16 11:43 出处:网络
When I run the java code I am getting the below error.. Below i have given my Java code... Please correct me if i am going wrong...

When I run the java code I am getting the below error.. Below i have given my Java code... Please correct me if i am going wrong...

junit.framework.AssertionFailedError: No tests found in pass
    at junit.framework.Assert.开发者_StackOverflow中文版fail(Assert.java:47)
    at junit.framework.TestSuite$1.runTest(TestSuite.java:90)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

import com.thoughtworks.selenium.*;
public class pass extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("https://secure02.monilink.co.uk/", "*chrome");
    }
    public pass() throws Exception {
/******** Below I am using my test environment URL **************/
        selenium.open("http:www.xxxxxxxxxxxxxx.com")
        selenium.type("username", "RSRK1");
        selenium.type("password", "");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.type("username", "S10");
        selenium.type("password", "56454");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Payments");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Pay Credit Card");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Select Card");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=exact:DEF Credit Card ************2016 Due Date: 19/09/10");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Select Account");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Current Account Created for Testing Purpose 11111111114 Balance: INR 6000.00");
        selenium.waitForPageToLoad("30000");
        selenium.type("amount", "20.00");
        selenium.type("transferDate", "190211");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Confirm");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Main menu");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Payments");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=View and Pay Bills");
        selenium.waitForPageToLoad("30000");
        selenium.click("_Select+bill1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=B.S.N.L, PUNJAB INR 135.00 due by 27/09/10");
        selenium.waitForPageToLoad("30000");
        selenium.click("_Select+account+or+card2_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Testing Account 11111111120 Balance: INR 1358.32");
        selenium.waitForPageToLoad("30000");
        selenium.type("paymentDateString", "190211");
        selenium.click("_Continue3_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Edit");
        selenium.waitForPageToLoad("30000");
        selenium.type("paymentDateString", "200211");
        selenium.click("_Continue3_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Confirm");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Main menu");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Logout");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Yes");
        selenium.waitForPageToLoad("30000");
    }
}

Thanks


Change the pass() method into something like testSomething(). You need to prefix your method name with test if you want to run JUnit. Or you can annotate your test method with @Test.

e.g:

import com.thoughtworks.selenium.*;

public class pass extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("https://secure02.monilink.co.uk/", "*chrome");
    }

    public testMePlease() throws Exception {

    }
}


JUnit is complaining because it can't find any tests. All of your test code is inside of your constructor. Create a void method with the @Test attribute before it. Put your selenium steps in it. JUnit will then find it and run it as a test.


Replace your code with this:

    import com.thoughtworks.selenium.*;
public class pass extends SeleneseTestCase {
    public void setUp() throws Exception {
        setUp("https://secure02.monilink.co.uk/", "*chrome");
    }
    public testPass() throws Exception {
/******** Below I am using my test environment URL **************/
        selenium.open("http:www.xxxxxxxxxxxxxx.com")
        selenium.type("username", "RSRK1");
        selenium.type("password", "");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.type("username", "S10");
        selenium.type("password", "56454");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Payments");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Pay Credit Card");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Select Card");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=exact:DEF Credit Card ************2016 Due Date: 19/09/10");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Select Account");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Current Account Created for Testing Purpose 11111111114 Balance: INR 6000.00");
        selenium.waitForPageToLoad("30000");
        selenium.type("amount", "20.00");
        selenium.type("transferDate", "190211");
        selenium.click("_Continue1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Confirm");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Main menu");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Payments");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=View and Pay Bills");
        selenium.waitForPageToLoad("30000");
        selenium.click("_Select+bill1_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=B.S.N.L, PUNJAB INR 135.00 due by 27/09/10");
        selenium.waitForPageToLoad("30000");
        selenium.click("_Select+account+or+card2_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Testing Account 11111111120 Balance: INR 1358.32");
        selenium.waitForPageToLoad("30000");
        selenium.type("paymentDateString", "190211");
        selenium.click("_Continue3_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Edit");
        selenium.waitForPageToLoad("30000");
        selenium.type("paymentDateString", "200211");
        selenium.click("_Continue3_button");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Confirm");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Main menu");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Logout");
        selenium.waitForPageToLoad("30000");
        selenium.click("link=Yes");
        selenium.waitForPageToLoad("30000");
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消