forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "TestSource" support to dynamic containers and tests
This commit introduces the support to add an instance of `java.net.URI` to a dynamic container or test by adding static factory methods that take a test source uri as a parameter. Prior to this commit the source for dynamic tests was always a `MethodSource` pointing to the `@TestFactory` annotated method. Now, for example, it is possible to refer to external files, that are the underlying sources of generated containers and tests. Addresses part of: junit-team#1178
- Loading branch information
Showing
11 changed files
with
326 additions
and
28 deletions.
There are no files selected for viewing
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
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
65 changes: 65 additions & 0 deletions
65
...m-engine/src/main/java/org/junit/platform/engine/support/descriptor/DefaultUriSource.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,65 @@ | ||
/* | ||
* Copyright 2015-2018 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junit.platform.engine.support.descriptor; | ||
|
||
import static org.apiguardian.api.API.Status.STABLE; | ||
|
||
import java.net.URI; | ||
import java.util.Objects; | ||
|
||
import org.apiguardian.api.API; | ||
import org.junit.platform.commons.util.Preconditions; | ||
import org.junit.platform.commons.util.ToStringBuilder; | ||
|
||
/** | ||
* Default uri-based test source implementation. | ||
* | ||
* @since 1.3 | ||
*/ | ||
@API(status = STABLE, since = "1.3") | ||
class DefaultUriSource implements UriSource { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final URI uri; | ||
|
||
DefaultUriSource(URI uri) { | ||
this.uri = Preconditions.notNull(uri, "uri must not be null"); | ||
} | ||
|
||
@Override | ||
public URI getUri() { | ||
return uri; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
DefaultUriSource that = (DefaultUriSource) o; | ||
return Objects.equals(this.uri, that.uri); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.uri); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this).append("uri", this.uri).toString(); | ||
} | ||
|
||
} |
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.