Skip to content

Commit 569d9ac

Browse files
author
Carsten Düllmann
committed
finished review, added hints for extra challenge
1 parent ddc974b commit 569d9ac

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

labs/08_testing/testing.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ First, let's make sure that you can actually work with your environment.
234234
235235
1. Open the repository when prompted.
236236
237-
1. Run the *build* task.
237+
1. Run the *build* task, choose "build" when asked for a task to run.
238238
239239
![UnitTests](./media/01-ui-test.png)
240240
@@ -260,7 +260,7 @@ If everything worked so far, you are good to go to the next task.
260260

261261
For our pipeline we will need tests that interact with our PartsUnlimited websites by automating a browser, thereby executing the full system end-to-end from the UI down to the database. This kind of tests typically only sees the UI end of the system though (everything behind that is a black box to them), which is why we often call them "UI Tests" synonymously.
262262

263-
We could create such tests from scratch, that would directly work with the elements in the website, just like we did in the previous task. However, such tests become unmaintainable quickly, which is why we would like to use the [Page Object Pattern](https://www.martinfowler.com/bliki/PageObject.html). Creating the code for such Page Objects is not complicated but would take a while doing it from scratch, thus we import an existing example from a github repository into our Azure DevOps project.
263+
We could create such tests from scratch - tests that directly work with the elements in the website, just like we did in the previous task. However, this kind of tests becomes unmaintainable quickly, which is why we would like to use the [Page Object Pattern](https://www.martinfowler.com/bliki/PageObject.html). Creating the code for Page Objects is not complicated but would take a while doing it from scratch, thus we import an existing example from a github repository into our Azure DevOps project.
264264

265265
1. Go to the Azure DevOps website and select *Repositories*. Hover over the pulldown menu in the top bar to open the Git repository menu. Select *Import repository*.
266266

@@ -312,7 +312,8 @@ We could create such tests from scratch, that would directly work with the eleme
312312
1. Now open the task list for the Dev environment.
313313
![UnitTests](./media/15-ui-test.png)
314314

315-
1. As our UI tests are .Net Core based, we need to change the build host to `Hosted 2017`.
315+
1. As our UI tests are .Net Core based, we need to change the build host to `Hosted 2017.
316+
316317
![UnitTests](./media/16-ui-test.png)
317318
318319
1. Next, add a new *.NET Core* step. It needs to be configured like this (also below a yaml configuration is listed to allow copy pasting into the textboxes)
@@ -331,6 +332,8 @@ We could create such tests from scratch, that would directly work with the eleme
331332
continueOnError: true
332333
```
333334
335+
1. In the *.NET Core* step you just added, expand "Advanced" and enter the value from the YAML above for the *Working Directory": `$(System.DefaultWorkingDirectory)/_parts-unlimited-web-driver-tests/drop`, which is the location where our test DLL from the build artifact will be found at run time.
336+
334337
1. Finally, add a *Publish Test Results* step.
335338
336339
![UnitTests](./media/18-ui-test.png)
@@ -369,10 +372,35 @@ We could create such tests from scratch, that would directly work with the eleme
369372
370373
![UnitTests](./media/22-ui-test.png)
371374
372-
1. Examine the test results. They should look very cheerfully - 4/4 green!
375+
1. Wait for the first stage of the pipeline to finish.
376+
377+
> In case you see errors, click on them to see the full log. There you might find something like *The test source file "D:\a\r1\a\PartsUnlimited.WebDriverTests.dll" provided was not found.*. Then probably you forgot to specify the WorkingDirectory in the .NET Core task in the previous task. Check all the settings of the task and repeat.
378+
379+
1. Then, in the summary page for the stage, click *Tests* and examine the test results. They should look very cheerfully - 4/4 green!
373380
374381
![UnitTests](./media/23-ui-test.png)
375382
376383
### Task 3: Extra Challenge: Create your own test with Page Objects
377384
378-
Now you have all the bits and pieces put together to start with something exploratory. Feel free to dig into the *Parts Unlimited* website and create an additional UI test, leveraging the and extending the *PageObject* infrastructure.
385+
Now you have all the bits and pieces put together to start with something exploratory. Feel free to dig into the *Parts Unlimited* website and create an additional UI test, leveraging the and extending the *PageObject* infrastructure.
386+
387+
* Start by adding a skeleton for a new test:
388+
389+
```c#
390+
[TestMethod]
391+
public void MyNewTest()
392+
{
393+
using (var dw = WebDriverProvider.CreateDriverWrapper(TestContext))
394+
{
395+
new HomePage(dw.Driver)
396+
// Enter test logic here
397+
}
398+
}
399+
```
400+
* Things you might want to try:
401+
* Use existing page objects in new combinations to explore new scenarios.
402+
* Add new methods to existing page objects (e.g. for enabling functionality that is in the product but not included in the page objects yet)
403+
* Add entirely new page object classes for pages of the application that were not yet explored by page objects.
404+
* Navigate to your live PartsUnlimted site and use the devoloper tools (F12 tools) of your browser to locate elements in the page and figure out ways how our page objects might find them (e.g. to be able to use `driver.FindElement(By.Id(""))` we would need to have an element that actually has an id set).
405+
406+
> Page Objects should not be created in advance but only once we encouter a test that needs something additional. This way we never waste effort on page objects that will not be needed anyways.

0 commit comments

Comments
 (0)