-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1179 from phac-nml/junit5-itest-refactor
Junit5 itest refactor
- Loading branch information
Showing
23 changed files
with
220 additions
and
154 deletions.
There are no files selected for viewing
Binary file modified
BIN
+41.6 KB
(140%)
doc/developer/interface/testing/images/intellij-ui-tests-default-junit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
1 change: 0 additions & 1 deletion
1
src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
ca.corefacility.bioinformatics.irida.junit5.listeners.UnitTestListener | ||
ca.corefacility.bioinformatics.irida.junit5.listeners.IntegrationTestListener | ||
ca.corefacility.bioinformatics.irida.junit5.listeners.IntegrationUITestListener |
60 changes: 60 additions & 0 deletions
60
src/test/java/ca/corefacility/bioinformatics/irida/config/IridaIntegrationTestUriConfig.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,60 @@ | ||
package ca.corefacility.bioinformatics.irida.config; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.test.web.client.LocalHostUriTemplateHandler; | ||
import org.springframework.boot.web.context.WebServerInitializedEvent; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.event.EventListener; | ||
|
||
import ca.corefacility.bioinformatics.irida.ria.integration.pages.AbstractPage; | ||
import ca.corefacility.bioinformatics.irida.ria.integration.utilities.RemoteApiUtilities; | ||
import ca.corefacility.bioinformatics.irida.ria.web.oauth.OltuAuthorizationController; | ||
import io.restassured.RestAssured; | ||
import io.restassured.builder.RequestSpecBuilder; | ||
import io.restassured.http.ContentType; | ||
|
||
/** | ||
* Configuration to be loaded in IntegrationTest via {@Link Import} annotation. | ||
* This waits for the servlet container initialized event and uses | ||
* {@Link LocalHostUriTemplateHandler} to retrieve the current URL to the servlet | ||
* container and set it up within the specific testing utilities. | ||
* | ||
* Also provides a {@Link LocalHostUriTemplateHandler} {@Link Bean} which can be used | ||
* in tests to access the servlet containers root uri. | ||
* | ||
*/ | ||
@TestConfiguration | ||
@Profile("it") | ||
public class IridaIntegrationTestUriConfig { | ||
|
||
private LocalHostUriTemplateHandler uriTemplateHandler; | ||
|
||
@Autowired | ||
private OltuAuthorizationController oltuAuthorizationController; | ||
|
||
@EventListener | ||
public void onServletContainerInitialized(WebServerInitializedEvent event) { | ||
uriTemplateHandler = new LocalHostUriTemplateHandler(event.getApplicationContext().getEnvironment()); | ||
String baseUrl = uriTemplateHandler.getRootUri() + "/"; | ||
AbstractPage.setBaseUrl(baseUrl); | ||
RemoteApiUtilities.setBaseUrl(baseUrl); | ||
oltuAuthorizationController.setServerBase(baseUrl); | ||
|
||
// Setup RestAssured | ||
RestAssured.requestSpecification = new RequestSpecBuilder() | ||
.setContentType(ContentType.JSON) | ||
.setAccept(ContentType.JSON) | ||
.setBaseUri(uriTemplateHandler.getRootUri()) | ||
.build(); | ||
} | ||
|
||
@Lazy | ||
@Bean | ||
public LocalHostUriTemplateHandler uriTemplateHandler() { | ||
return uriTemplateHandler; | ||
} | ||
|
||
} |
28 changes: 0 additions & 28 deletions
28
src/test/java/ca/corefacility/bioinformatics/irida/config/IridaWebTestScopeConfig.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...t/java/ca/corefacility/bioinformatics/irida/junit5/listeners/IntegrationTestListener.java
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.