如果函数具有__block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^(void) {
[application endBackgroundTask:backgroundTaskIdentifier];
NSLog(@"applicationWillResignActive");
[__SERVER_INSTANCE cancellAllDownloading];
// recreate here your request to finish fownload,
//or recreate in when app will enter foreground
}];
注释,是否有任何方法可以在函数中使用参数。我有一个如下功能:
@test
然而,当我试图运行上面的代码时,它给了我错误:
方法Home_page_Flextronics需要2个参数,但提供了0 在@Test注释中。
如果我删除参数并使用硬编码值,它的工作正常,这是我的框架的要求。我已经通过其他解决方案,主要建议使用@Test(@Test(priority=1, alwaysRun =true))
public void Home_page_Flextronics(String sUserName, String sPassword) throws FileNotFoundException
{
CommonFunctions.LaunchApplication();
CommonFunctions.Login(sUserName, sPassword);
CommonFunctions.ClickOnModule("Customers");
CommonFunctions.ClickOnHome();
CommonFunctions.Logout();
}
注释或数据提供程序。但我不想使用它,因为我想从excel表中获取testdata。如果还有其他办法可以解决这个问题,请告诉我。感谢您的帮助。
答案 0 :(得分:1)
你可以看看Junit Theories (introduction)
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
@RunWith(Theories.class)
public class AdditionWithTheoriesTest {
@DataPoints
public static int[] positiveIntegers() {
return new int[]{
1, 10, 1234567};
}
@Theory
public void a_plus_b_is_greater_than_a_and_greater_than_b(Integer a, Integer b) {
assertTrue(a + b > a);
assertTrue(a + b > b);
}
}
这样您就可以将参数传递给测试。在使用DataPoints注释的方法中,您需要获取所有excell数据并将其返回。