类org.testng.asserts.SoftAssert源码实例Demo

下面列出了怎么用org.testng.asserts.SoftAssert的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: aquality-selenium-java   文件: ElementTests.java
@Test
public void testTextBox() {
    navigate(TheInternetPage.LOGIN);
    FormAuthenticationForm authenticationForm = new FormAuthenticationForm();
    SoftAssert softAssert = new SoftAssert();

    ITextBox txbUsername = authenticationForm.getTxbUsername();
    txbUsername.focus();
    txbUsername.type("wrong");
    softAssert.assertEquals(txbUsername.getValue(), "wrong");

    ITextBox txbPass = authenticationForm.getTxbPassword();
    txbPass.sendKeys(Keys.NUMPAD0);
    softAssert.assertEquals(txbPass.getValue(), "0");

    txbPass.submit();
    String expectedValue = "";
    boolean result = AqualityServices.getConditionalWait().waitFor(() -> txbPass.getValue().equalsIgnoreCase(expectedValue), "Value of textbox should be equal " + expectedValue);
    softAssert.assertTrue(result);
    softAssert.assertAll();
}
 
源代码2 项目: SearchServices   文件: AbstractBackupE2ETest.java
/**
 * Will assert that @param count files starting with @param filePrefix are found
 * inside @param folder
 */
protected File[] assertFileExistInLocalBackupFolder(String folder, String filePrefix, int count) {

	File backupLocation = Paths.get("./qa/search/backup/host-bkp", folder).toFile();

	Assert.assertTrue(backupLocation.exists(), "Backup location exists: " + backupLocation.getAbsolutePath());
	if (count >= 1) {
		Assert.assertEquals(backupLocation.listFiles().length, count,
				"Expected Files in folder:" + backupLocation.getPath());

		SoftAssert soft = new SoftAssert();
		for (File file : backupLocation.listFiles()) {
			soft.assertTrue(file.getName().startsWith(filePrefix),
					String.format("File [%s] starts with prefix: %s", file.getPath(), filePrefix));
		}
		soft.assertAll();

		return backupLocation.listFiles();
	} else {
		Assert.assertEquals(backupLocation.listFiles().length, 0, backupLocation.getPath() + "should be empty!");
	}

	return null;

}
 
源代码3 项目: morpheus-core   文件: ArrayConcatTest.java
private void assertArrayElementEqualsTo(
        final Array<DataFrame<Integer, Month>> array,
        final DataFrame<Integer, Month> ...elements)
{
    if(array.length() != elements.length){
        throw new IllegalArgumentException("Parameters array and elements must have the same length");
    }

    final SoftAssert softAssert = new SoftAssert();

    for (int i = 0; i < array.length(); i++) {
        softAssert.assertEquals(array.getValue(i), elements[i],"Element "+i+" of the array: ");
    }

    softAssert.assertAll();
}
 
源代码4 项目: aquality-selenium-java   文件: ShoppingCartTest.java
@Test
public void testShoppingCart() {
    AqualityServices.getBrowser().getDriver().navigate().to(URL_AUTOMATIONPRACTICE);
    SoftAssert softAssert = new SoftAssert();

    SliderForm sliderForm = new SliderForm();
    Assert.assertTrue(sliderForm.isDisplayed());

    sliderForm.clickBtnNext();
    sliderForm.clickBtnNext();
    ProductListForm productListForm = new ProductListForm();
    List<ILabel> productList = productListForm.getProductContainerLabels();
    softAssert.assertEquals(productList.size(), 7);

    productListForm.addToCardRandomProduct();
    ProceedToCheckoutModal proceedToCheckoutModal = new ProceedToCheckoutModal();
    proceedToCheckoutModal.getBtnProceedToCheckout().getJsActions().clickAndWait();
    ShoppingCardSummaryForm shoppingCardSummaryForm = new ShoppingCardSummaryForm();
    shoppingCardSummaryForm.getBtnPlus().getJsActions().click();
    Integer expectedQuantity = 2;
    Integer actualQuantity = shoppingCardSummaryForm.waitForQuantityAndGetValue(expectedQuantity);
    softAssert.assertEquals(expectedQuantity, actualQuantity, "Quantity is not correct");

    shoppingCardSummaryForm.clickProceedToCheckoutBtn();
    softAssert.assertTrue(new AuthenticationForm().isDisplayed());
    CartMenuForm cartMenuForm = new CartMenuForm();
    cartMenuForm.openCartMenu();
    cartMenuForm.clickCheckoutBtn();
    shoppingCardSummaryForm.clickProceedToCheckoutBtn();
    AuthenticationForm authenticationForm = new AuthenticationForm();
    authenticationForm.setEmail(getUserEmail());
    authenticationForm.clickCreateAccountBtn();
    YourPersonalInfoForm yourPersonalInfoForm = new YourPersonalInfoForm();
    yourPersonalInfoForm.selectGender(1);
    yourPersonalInfoForm.setFirstName(USER_FIRST_NAME);
    Integer expectedNumOfDays = 32;
    Integer actualNumOfDays = yourPersonalInfoForm.getNumOfDays();
    softAssert.assertEquals(expectedNumOfDays, actualNumOfDays, "Num of days from combobox is not correct");

    yourPersonalInfoForm.selectState(STATE);
    yourPersonalInfoForm.selectDay(29);
    boolean expectedStateOfNewsChb = false;
    boolean actualStateOfNewsChb = yourPersonalInfoForm.getNewsCheckBoxState();
    String errorMessage = "News checkbox state is not correct";
    softAssert.assertEquals(expectedStateOfNewsChb, actualStateOfNewsChb, errorMessage);

    yourPersonalInfoForm.setNewsChb();
    softAssert.assertTrue(yourPersonalInfoForm.getNewsCheckBoxState(), errorMessage);
    softAssert.assertTrue(yourPersonalInfoForm.isNewsCheckboxChecked(), errorMessage);
    softAssert.assertAll();
}
 
 类所在包
 类方法
 同包方法