I've created a basic test for checking if some article is displayed and I have a question regarding Page object model. In my solution, I've testing page, base page, map page with element id's, and method page with main logic. Test is something like - open site, navigate to articles, search for 'ArticleX', click on it, add it to the basket, edit the basket. For those operations, I've created 5 tests in my testing page, but now wondering is correct, or I should reduce them? All of them have repeated methods, which I test, for example the last test, called 'Edit basket'. I performing the following operations:
[Test]
public void TestEditBasket() {
logicPage = new LogicPage();
logicPage.NavigateTo();
logicPage.ClickArticles();
logicPage.SearchArticleX();
logicPage.PressArticleX();
logicPage.AddArticleXToBasket();
logicPage.EditBasket();
//this test only checks name, quantity, price when you're editing basket
Assert.IsTrue(logicPage.ArticleNameInBasket.Text.Contains("ArticleXHeading"));
Assert.IsTrue(logicPage.ArticleQuantityInBasket.Text.Contains("1"));
Assert.IsTrue(logicPage.ArticlePriceInBasket.Text.Contains("$10"));
NavigateTo, ClickArticles, SearchArticleX, PressArticleX, AddArticleXToBasket are already tested in the previous tests, but I cannot go directly to the last step - EditBasket, that's why I'm using them in this test.
How the other tests looks like:
[Test1]
public void VerifyPageOpened() {
logicPage = new LogicPage();
logicPage.NavigateTo();
Assert.IsTrue());
Assert.IsTrue());
[Test2]
public void TestSearchingArticleX() {
logicPage = new LogicPage();
logicPage.NavigateTo();
logicPage.ClickArticles();
Assert.IsTrue());
Assert.IsTrue());
[Test3]
public void TestClickOnArticleX() {
logicPage = new LogicPage();
logicPage.NavigateTo();
logicPage.ClickArticles();
logicPage.PressArticleX();
Assert.IsTrue());
Assert.IsTrue());
[Test4]
public void TestAddArticleXInBasket() {
logicPage = new LogicPage();
logicPage.NavigateTo();
logicPage.ClickArticles();
logicPage.PressArticleX();
logicPage.AddArticleXToBasket();
Assert.IsTrue());
Assert.IsTrue());
I can delete the other tests and left only this one. But will add around of 10 more asserts. Any advice?
question from:
https://stackoverflow.com/questions/66060391/repeateable-methods-testing-while-using-page-object-model 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…