Conversation
a boolean test/not-a-test. Instead, now it's an enum that the users can extend.
Related PR: #539.
Codecov Report
@@ Coverage Diff @@
## master #539 +/- ##
============================================
+ Coverage 73.71% 73.80% +0.09%
- Complexity 2936 2954 +18
============================================
Files 503 506 +3
Lines 11904 11954 +50
Branches 670 669 -1
============================================
+ Hits 8775 8823 +48
+ Misses 2905 2904 -1
- Partials 224 227 +3 |
|
@armiol, PTAL. |
armiol
left a comment
There was a problem hiding this comment.
@serhii-lekariev please see my comments.
Correct some docs errors.
Also update config.
# Conflicts: # license-report.md # version.gradle.kts
|
@armiol, PTAL again. |
| /** | ||
| * Provides information about the environment (current platform used, etc.). | ||
| * | ||
| * <p><b>When extending, please note</b> that this class does not handle the situations when two |
There was a problem hiding this comment.
Let's rephrase in terms of the responsibitliy of the framework user. It's not that this class handles or does not handle any use cases. It just delegates the responsibility to tell between different PRODUCTION environments to the developer writing the code.
|
@armiol, PTAL again. |
armiol
left a comment
There was a problem hiding this comment.
@serhii-lekariev please see my comments.
| @@ -159,15 +159,15 @@ void mutateKnownEnvTypesOnce() { | |||
| @Test | |||
| @DisplayName("throw if a user attempts to create register the same environment twice") | |||
| void throwOnDoubleCreation() { | |||
| * {@link EnvironmentType#enabled()}. As such, if two or more user-defined environment types | ||
| * think that they are currently enabled, <b>the behaviour of {@link #currentType()} is | ||
| * undefined.</b> | ||
| * <p><b>When extending, please ensure</b> the mutual exclusivity on your {@code EnvironmentType}s. |
There was a problem hiding this comment.
This class cannot be extended. Please put a bit more into this thought.
|
@armiol, PTAL again. |
Shorten the `currentType()` to `type()` and un-mark the `register(type)` as `@Internal`.
…rentType()` to make it simpler for the callers. Make `EnvironmentType` into an `abstract class` to ensure a more strict access level of the `active` method.
armiol
left a comment
There was a problem hiding this comment.
@serhii-lekariev mostly LGTM. Please see my comments.
| /** | ||
| * Returns the singleton instance. | ||
| */ | ||
| public static Production instance() { |
There was a problem hiding this comment.
Let's call it type().
Don't forget to update the code samples in the documentation.
| || stacktrace.contains("org.testng")) { | ||
| this.tests = true; | ||
| return true; | ||
| public boolean is(EnvironmentType type) { |
There was a problem hiding this comment.
Let's bring back isTests() and isProduction() and mark them @Deprecated in favor of ... .enabled().
It's a proper way of propagating the public API changes.
| /** | ||
| * Returns the singleton instance of this class. | ||
| */ | ||
| public static Tests instance() { |
|
@armiol, PTAL again. |
a concrete instance in hands.
This PR extends the
EnvironmentAPI to allow the definition of custom environment types. It also migrates the current boolean test/not-a-test setup to a class-based solution.To register a new environment type, define a custom one like so:
When checking the environment types, user-defined types are checked first. If no type was found to be
enabled, falls back toio.spine.base.Production.Deprecation notes
The following methods are now deprecated in favor of the new API:
isTests: useis(Tests.type());;setToTests: usesetTo(Tests.type());;isProduction: useis(Production.type());;setToProduction: usesetTo(Production.type());.