我有三個方案,Java的傳球價值
首先進行Selenium測試
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import junit.framework.*;
public class MyTest extends SeleneseTestCase {
int flag_eco;
public void setUp() throws Exception {
setUp("http://www.mysite.com/", "*iexplore");
}
public void testMyTest() throws Exception {
selenium.open("/pages/static/homepage_logout.html");
selenium.type("username", "myuser");
selenium.type("password", "password");
selenium.click("//input[@value='LOGIN']");
selenium.waitForPageToLoad("30000");
selenium.click("Confirm");
selenium.waitForPageToLoad("30000");
selenium.click("link=Applications");
selenium.waitForPageToLoad("30000");
selenium.click("link=Journey");
selenium.waitForPageToLoad("30000");
selenium.click("link=Launch Application (MUST BE LOGGED IN)");
selenium.waitForPageToLoad("30000");
if((selenium.isTextPresent("Please enter one of the following:")))
{
System.out.println("Journey Working Fine");
flag_test= 0;
}
else
{
System.out.println("Journey Failed");
flag_test = 1;
}
selenium.selectFrame("topmenu");
selenium.click("link=Home");
}
public static Test suite() {
//method added
return new TestSuite(MyTest.class);
}
public void tearDown(){
//Added . Will be called when the test will complete
selenium.stop();
}
}
那麼sendmail的從Selenium測試剛開值
import java.util.*;
public class SendMail
{
public void send()
{
MyTest Test = new MyTest();
if (Test.flag_test==1)
{
System.out.println("Journey Failed");
}
else if(Test.flag_test==0)
{
System.out.println("Journey Working Fine");
}
} }
主類調用這兩個
import java.io.*;
import javax.servlet.*;
public class Test
{
public static void main(String args[])
{
MyTest tes = new MyTest();
junit.textui.TestRunner.run(tes.suite());
SendMail se = new SendMail();
se.send();
}
}
如何傳遞的標誌值從MyTest的Sendmail的
據我所知,MyTest上沒有靜態的'flag'字段。 – danben
爲什麼downvote?我表示這是錯誤的,但這是唯一的方法。他不控制他的班級實例,所以他不能通過任何參考neigther從測試類 – Bozho
@danben是的,我說這個標誌_應該是靜態的。我沒有看到它的定義,但這是要走的路 – Bozho