diff --git a/framework-docs/src/docs/asciidoc/testing/spring-mvc-test-framework.adoc b/framework-docs/src/docs/asciidoc/testing/spring-mvc-test-framework.adoc index 234c6db850..6d0648cd53 100644 --- a/framework-docs/src/docs/asciidoc/testing/spring-mvc-test-framework.adoc +++ b/framework-docs/src/docs/asciidoc/testing/spring-mvc-test-framework.adoc @@ -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 message with the following: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -1440,9 +1441,11 @@ message with the following: ---- val page = CreateMessagePage.to(driver) ---- +-- 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"] .Java ---- @@ -1456,6 +1459,7 @@ We can then fill out the form and submit it to create a message, as follows: val viewMessagePage = page.createMessage(ViewMessagePage::class, expectedSummary, expectedText) ---- +-- This improves on the design of our <> 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 `CreateMessagePage` implementation: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .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] 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]*). - +-- Finally, we can verify that a new message was created successfully. The following assertions use the https://assertj.github.io/doc/[AssertJ] assertion library: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -1568,10 +1574,12 @@ assertions use the https://assertj.github.io/doc/[AssertJ] assertion library: assertThat(viewMessagePage.message).isEqualTo(expectedMessage) assertThat(viewMessagePage.success).isEqualTo("Successfully created a new message") ---- +-- 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: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -1589,12 +1597,14 @@ example, it exposes a method that returns a `Message` object: ---- fun getMessage() = Message(getId(), getCreated(), getSummary(), getText()) ---- +-- 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, as follows: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -1616,6 +1626,7 @@ as follows: } } ---- +-- For additional information on using WebDriver, see the Selenium https://github.com/SeleniumHQ/selenium/wiki/Getting-Started[WebDriver documentation]. diff --git a/framework-docs/src/docs/asciidoc/testing/testcontext-framework.adoc b/framework-docs/src/docs/asciidoc/testing/testcontext-framework.adoc index f7f524389c..ed8e029e3d 100644 --- a/framework-docs/src/docs/asciidoc/testing/testcontext-framework.adoc +++ b/framework-docs/src/docs/asciidoc/testing/testcontext-framework.adoc @@ -644,7 +644,7 @@ path that represents a resource URL (i.e., a path prefixed with `classpath:`, `f @ExtendWith(SpringExtension::class) // ApplicationContext will be loaded from "/app-config.xml" and // "/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 body... } @@ -667,7 +667,7 @@ demonstrated in the following example: // 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"] .Kotlin @@ -678,7 +678,7 @@ demonstrated in the following example: // 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 @@ -743,6 +743,7 @@ The following example shows how to specify Groovy configuration files: // class body... } ---- +<1> Specifying the location of Groovy configuration files. [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin diff --git a/framework-docs/src/docs/asciidoc/testing/testing-annotations.adoc b/framework-docs/src/docs/asciidoc/testing/testing-annotations.adoc index eebef6f9a4..9e6edbeb9b 100644 --- a/framework-docs/src/docs/asciidoc/testing/testing-annotations.adoc +++ b/framework-docs/src/docs/asciidoc/testing/testing-annotations.adoc @@ -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: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -231,6 +232,7 @@ The following example shows how to use the `@WebAppConfiguration` annotation: // class body... } ---- +<1> The `@WebAppConfiguration` annotation. [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] .Kotlin @@ -242,6 +244,7 @@ The following example shows how to use the `@WebAppConfiguration` annotation: } ---- <1> The `@WebAppConfiguration` annotation. +-- 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 resource. The following example shows how to specify a classpath resource: +-- [source,java,indent=0,subs="verbatim,quotes",role="primary"] .Java ---- @@ -270,6 +274,7 @@ resource. The following example shows how to specify a classpath resource: } ---- <1> Specifying a classpath resource. +-- 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> @Sql(scripts = "/test-schema.sql", config = @SqlConfig(commentPrefix = "`")), @Sql("/test-user-data.sql") - )} + }) void userTest() { // run code that uses the test schema and test data }