Fix errors in Testing chapter
- group code example callouts to ensure callouts are displayed for the correct examples - add missing callouts - fix syntax, annotation attribute names, etc.
This commit is contained in:
		
							parent
							
								
									3afc6a5079
								
							
						
					
					
						commit
						2847621928
					
				| 
						 | 
					@ -1429,6 +1429,7 @@ Now we can use WebDriver as we normally would but without the need to deploy our
 | 
				
			||||||
application to a Servlet container. For example, we can request the view to create a
 | 
					application to a Servlet container. For example, we can request the view to create a
 | 
				
			||||||
message with the following:
 | 
					message with the following:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1440,9 +1441,11 @@ message with the following:
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
	val page = CreateMessagePage.to(driver)
 | 
						val page = CreateMessagePage.to(driver)
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
We can then fill out the form and submit it to create a message, as follows:
 | 
					We can then fill out the form and submit it to create a message, as follows:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1456,6 +1459,7 @@ We can then fill out the form and submit it to create a message, as follows:
 | 
				
			||||||
	val viewMessagePage =
 | 
						val viewMessagePage =
 | 
				
			||||||
		page.createMessage(ViewMessagePage::class, expectedSummary, expectedText)
 | 
							page.createMessage(ViewMessagePage::class, expectedSummary, expectedText)
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This improves on the design of our <<spring-mvc-test-server-htmlunit-mah-usage, HtmlUnit test>>
 | 
					This improves on the design of our <<spring-mvc-test-server-htmlunit-mah-usage, HtmlUnit test>>
 | 
				
			||||||
by leveraging the Page Object Pattern. As we mentioned in
 | 
					by leveraging the Page Object Pattern. As we mentioned in
 | 
				
			||||||
| 
						 | 
					@ -1463,6 +1467,7 @@ by leveraging the Page Object Pattern. As we mentioned in
 | 
				
			||||||
with HtmlUnit, but it is much easier with WebDriver. Consider the following
 | 
					with HtmlUnit, but it is much easier with WebDriver. Consider the following
 | 
				
			||||||
`CreateMessagePage` implementation:
 | 
					`CreateMessagePage` implementation:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1551,11 +1556,12 @@ by the `id` or `name` of the element within the HTML page.
 | 
				
			||||||
https://github.com/SeleniumHQ/selenium/wiki/PageFactory#making-the-example-work-using-annotations[`@FindBy` annotation]
 | 
					https://github.com/SeleniumHQ/selenium/wiki/PageFactory#making-the-example-work-using-annotations[`@FindBy` annotation]
 | 
				
			||||||
to override the default lookup behavior. Our example shows how to use the `@FindBy`
 | 
					to override the default lookup behavior. Our example shows how to use the `@FindBy`
 | 
				
			||||||
annotation to look up our submit button with a `css` selector (*input[type=submit]*).
 | 
					annotation to look up our submit button with a `css` selector (*input[type=submit]*).
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Finally, we can verify that a new message was created successfully. The following
 | 
					Finally, we can verify that a new message was created successfully. The following
 | 
				
			||||||
assertions use the https://assertj.github.io/doc/[AssertJ] assertion library:
 | 
					assertions use the https://assertj.github.io/doc/[AssertJ] assertion library:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1568,10 +1574,12 @@ assertions use the https://assertj.github.io/doc/[AssertJ] assertion library:
 | 
				
			||||||
	assertThat(viewMessagePage.message).isEqualTo(expectedMessage)
 | 
						assertThat(viewMessagePage.message).isEqualTo(expectedMessage)
 | 
				
			||||||
	assertThat(viewMessagePage.success).isEqualTo("Successfully created a new message")
 | 
						assertThat(viewMessagePage.success).isEqualTo("Successfully created a new message")
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
We can see that our `ViewMessagePage` lets us interact with our custom domain model. For
 | 
					We can see that our `ViewMessagePage` lets us interact with our custom domain model. For
 | 
				
			||||||
example, it exposes a method that returns a `Message` object:
 | 
					example, it exposes a method that returns a `Message` object:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1589,12 +1597,14 @@ example, it exposes a method that returns a `Message` object:
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
	fun getMessage() = Message(getId(), getCreated(), getSummary(), getText())
 | 
						fun getMessage() = Message(getId(), getCreated(), getSummary(), getText())
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
We can then use the rich domain objects in our assertions.
 | 
					We can then use the rich domain objects in our assertions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Lastly, we must not forget to close the `WebDriver` instance when the test is complete,
 | 
					Lastly, we must not forget to close the `WebDriver` instance when the test is complete,
 | 
				
			||||||
as follows:
 | 
					as follows:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -1616,6 +1626,7 @@ as follows:
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
For additional information on using WebDriver, see the Selenium
 | 
					For additional information on using WebDriver, see the Selenium
 | 
				
			||||||
https://github.com/SeleniumHQ/selenium/wiki/Getting-Started[WebDriver documentation].
 | 
					https://github.com/SeleniumHQ/selenium/wiki/Getting-Started[WebDriver documentation].
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -644,7 +644,7 @@ path that represents a resource URL (i.e., a path prefixed with `classpath:`, `f
 | 
				
			||||||
	@ExtendWith(SpringExtension::class)
 | 
						@ExtendWith(SpringExtension::class)
 | 
				
			||||||
	// ApplicationContext will be loaded from "/app-config.xml" and
 | 
						// ApplicationContext will be loaded from "/app-config.xml" and
 | 
				
			||||||
	// "/test-config.xml" in the root of the classpath
 | 
						// "/test-config.xml" in the root of the classpath
 | 
				
			||||||
	@ContextConfiguration("/app-config.xml", "/test-config.xml") // <1>
 | 
						@ContextConfiguration(locations = ["/app-config.xml", "/test-config.xml"]) // <1>
 | 
				
			||||||
	class MyTest {
 | 
						class MyTest {
 | 
				
			||||||
		// class body...
 | 
							// class body...
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -667,7 +667,7 @@ demonstrated in the following example:
 | 
				
			||||||
		// class body...
 | 
							// class body...
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
<1> Specifying XML files without using the `location` attribute.
 | 
					<1> Specifying XML files without using the `locations` attribute.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
					[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
				
			||||||
.Kotlin
 | 
					.Kotlin
 | 
				
			||||||
| 
						 | 
					@ -678,7 +678,7 @@ demonstrated in the following example:
 | 
				
			||||||
		// class body...
 | 
							// class body...
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
<1> Specifying XML files without using the `location` attribute.
 | 
					<1> Specifying XML files without using the `locations` attribute.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you omit both the `locations` and the `value` attributes from the
 | 
					If you omit both the `locations` and the `value` attributes from the
 | 
				
			||||||
| 
						 | 
					@ -743,6 +743,7 @@ The following example shows how to specify Groovy configuration files:
 | 
				
			||||||
		// class body...
 | 
							// class body...
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					<1> Specifying the location of Groovy configuration files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
					[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
				
			||||||
.Kotlin
 | 
					.Kotlin
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -222,6 +222,7 @@ resource base path). The resource base path is used behind the scenes to create
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The following example shows how to use the `@WebAppConfiguration` annotation:
 | 
					The following example shows how to use the `@WebAppConfiguration` annotation:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -231,6 +232,7 @@ The following example shows how to use the `@WebAppConfiguration` annotation:
 | 
				
			||||||
		// class body...
 | 
							// class body...
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
 | 
					<1> The `@WebAppConfiguration` annotation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
					[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
 | 
				
			||||||
.Kotlin
 | 
					.Kotlin
 | 
				
			||||||
| 
						 | 
					@ -242,6 +244,7 @@ The following example shows how to use the `@WebAppConfiguration` annotation:
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
<1> The `@WebAppConfiguration` annotation.
 | 
					<1> The `@WebAppConfiguration` annotation.
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
To override the default, you can specify a different base resource path by using the
 | 
					To override the default, you can specify a different base resource path by using the
 | 
				
			||||||
| 
						 | 
					@ -249,6 +252,7 @@ implicit `value` attribute. Both `classpath:` and `file:` resource prefixes are
 | 
				
			||||||
supported. If no resource prefix is supplied, the path is assumed to be a file system
 | 
					supported. If no resource prefix is supplied, the path is assumed to be a file system
 | 
				
			||||||
resource. The following example shows how to specify a classpath resource:
 | 
					resource. The following example shows how to specify a classpath resource:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
					[source,java,indent=0,subs="verbatim,quotes",role="primary"]
 | 
				
			||||||
.Java
 | 
					.Java
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
| 
						 | 
					@ -270,6 +274,7 @@ resource. The following example shows how to specify a classpath resource:
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
<1> Specifying a classpath resource.
 | 
					<1> Specifying a classpath resource.
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note that `@WebAppConfiguration` must be used in conjunction with
 | 
					Note that `@WebAppConfiguration` must be used in conjunction with
 | 
				
			||||||
| 
						 | 
					@ -1104,7 +1109,7 @@ annotation. The following example shows how to declare an SQL group:
 | 
				
			||||||
	@SqlGroup({ // <1>
 | 
						@SqlGroup({ // <1>
 | 
				
			||||||
		@Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`")),
 | 
							@Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`")),
 | 
				
			||||||
		@Sql("/test-user-data.sql")
 | 
							@Sql("/test-user-data.sql")
 | 
				
			||||||
	)}
 | 
						})
 | 
				
			||||||
	void userTest() {
 | 
						void userTest() {
 | 
				
			||||||
		// run code that uses the test schema and test data
 | 
							// run code that uses the test schema and test data
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue