-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced useless unit-tests by analogous integration test
- Loading branch information
Showing
4 changed files
with
74 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
src/test/java/com/codeborne/selenide/collections/SizeNotEqualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/test/java/integration/collections/SizeNotEqualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package integration.collections; | ||
|
||
import com.codeborne.selenide.ElementsCollection; | ||
import com.codeborne.selenide.ex.ElementNotFound; | ||
import com.codeborne.selenide.ex.ListSizeMismatch; | ||
import integration.ITest; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.NoSuchElementException; | ||
|
||
import static com.codeborne.selenide.CollectionCondition.size; | ||
import static com.codeborne.selenide.CollectionCondition.sizeNotEqual; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
public class SizeNotEqualTest extends ITest { | ||
|
||
@BeforeEach | ||
void openPage() { | ||
openFile("page_with_selects_without_jquery.html"); | ||
} | ||
|
||
@Test | ||
void size_notEqual() { | ||
$$("#radioButtons input").shouldHave(size(4)); | ||
$$("#radioButtons input").shouldHave(sizeNotEqual(3)); | ||
$$("#radioButtons input").shouldHave(sizeNotEqual(5)); | ||
} | ||
|
||
@Test | ||
void size_notEqual_failure() { | ||
assertThatThrownBy(() -> $$("#radioButtons input").shouldHave(sizeNotEqual(4))) | ||
.isInstanceOf(ListSizeMismatch.class) | ||
.hasMessageStartingWith("List size mismatch") | ||
.hasMessageContaining("expected: <> 4, actual: 4") | ||
.hasMessageContaining("collection: #radioButtons input") | ||
.hasMessageContaining(""" | ||
Elements: [ | ||
\t<input name="me" type="radio" value="master"></input>, | ||
\t<input name="me" type="radio" value="margarita"></input>, | ||
\t<input name="me" type="radio" value="cat"></input>, | ||
\t<input name="me" type="radio" value="woland"></input> | ||
]"""); | ||
} | ||
|
||
@Test | ||
void emptyCollection() { | ||
$$("not-existing-locator").shouldHave(sizeNotEqual(3)); | ||
} | ||
|
||
@Test | ||
void emptyFilteredCollection() { | ||
ElementsCollection collection = $$("not-existing-locator").first().$$("#multirowTable"); | ||
|
||
assertThatThrownBy(() -> collection.shouldHave(sizeNotEqual(0))) | ||
.isInstanceOf(ListSizeMismatch.class) | ||
.hasMessageStartingWith("List size mismatch") | ||
.hasMessageContaining("expected: <> 0") | ||
.hasMessageContaining("actual: 0") | ||
.hasMessageContaining("collection: not-existing-locator[0]/#multirowTable") | ||
.hasCauseExactlyInstanceOf(NoSuchElementException.class); | ||
} | ||
|
||
@Test | ||
void emptyCollectionByIndex() { | ||
ElementsCollection collection = $$("not-existing-locator").get(1).$$("#multirowTable"); | ||
|
||
assertThatThrownBy(() -> collection.shouldHave(sizeNotEqual(0))) | ||
.isInstanceOf(ElementNotFound.class) | ||
.hasMessageStartingWith("Element not found {not-existing-locator[1]/#multirowTable}") | ||
.hasCauseExactlyInstanceOf(IndexOutOfBoundsException.class); | ||
} | ||
} |