我想从testng xml向测试用例传递一个动态参数,我的参数类似于:
String dynamicParameter=generateRandomStringForMail();下面是我的测试用例:
@Test()
public void customerCreatorAllProducts () throws Exception {
setup();
Functions.pages.LoginPage login = PageFactory.initElements(driver, Functions.pages.LoginPage.class);
login.navigateRegisterPage().createFixedPasswordCustomerRequiredFields(dynamicParameter);
}我也会在其他情况下使用这个参数,我如何在testng.xml或其他地方使用这个参数呢?
发布于 2020-08-05 08:15:47
我对testing.xml并不熟悉,但是我马上就想到了http://mockito.org。
import static org.mockito.Mockito.*;DefaultFileService mockFileService = mock(DefaultFileService.class);when(mockFileService.generateRandomFileName()).thenReturn("fileName");quiltController.update(data, mockFile);
verify(mockFileService).save(mockFile, "fileName"); // confirms the save() method was called with the expected parameters这感觉很像你正在尝试做的事情,所以如果你真的想要探索Mockito,希望这能帮助你继续下去。如果您需要重构某些工作以使其更具可测试性,请不要感到惊讶。我做到了,并因此获得了更好的代码。试一试:)
https://stackoverflow.com/questions/63256545
复制相似问题