pub struct SoftAssertions { /* private fields */ }Expand description
A context for collecting soft assertions.
Soft assertions allow you to make multiple assertions without stopping on the first failure. All failures are collected and can be checked at the end.
Implementations§
Source§impl SoftAssertions
impl SoftAssertions
Sourcepub fn expect<'a>(&self, locator: &'a Locator<'a>) -> SoftLocatorAssertions<'a>
pub fn expect<'a>(&self, locator: &'a Locator<'a>) -> SoftLocatorAssertions<'a>
Create soft assertions for a locator.
Assertions made through this will not fail immediately, but will be collected for later inspection.
§Example
use viewpoint_test::SoftAssertions;
let soft = SoftAssertions::new();
let locator = page.locator("h1");
soft.expect(&locator).to_be_visible().await;
soft.expect(&locator).to_have_text("Example Domain").await;
soft.assert_all().unwrap();Sourcepub fn expect_page<'a>(&self, page: &'a Page) -> SoftPageAssertions<'a>
pub fn expect_page<'a>(&self, page: &'a Page) -> SoftPageAssertions<'a>
Create soft assertions for a page.
§Example
use viewpoint_test::SoftAssertions;
let soft = SoftAssertions::new();
soft.expect_page(&page).to_have_url("https://example.com/").await;
soft.assert_all().unwrap();Sourcepub fn errors(&self) -> Vec<SoftAssertionError>
pub fn errors(&self) -> Vec<SoftAssertionError>
Get all collected errors.
Sourcepub fn failure_count(&self) -> usize
pub fn failure_count(&self) -> usize
Get the number of failed assertions.
Sourcepub fn assert_all(&self) -> Result<(), TestError>
pub fn assert_all(&self) -> Result<(), TestError>
Assert that all soft assertions passed.
This will fail with a combined error message if any assertions failed.
§Errors
Returns an error containing all assertion failures if any occurred.
Sourcepub fn add_error(&self, error: SoftAssertionError)
pub fn add_error(&self, error: SoftAssertionError)
Add an error to the collection.
Trait Implementations§
Source§impl Clone for SoftAssertions
impl Clone for SoftAssertions
Source§fn clone(&self) -> SoftAssertions
fn clone(&self) -> SoftAssertions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SoftAssertions
impl Debug for SoftAssertions
Auto Trait Implementations§
impl Freeze for SoftAssertions
impl RefUnwindSafe for SoftAssertions
impl Send for SoftAssertions
impl Sync for SoftAssertions
impl Unpin for SoftAssertions
impl UnwindSafe for SoftAssertions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more