-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose IErrorContext in ErrorInfo...
Prior to this commit, IRunListener.error(ErrorInfo) didn't give any context where the error happened.
- Loading branch information
Showing
12 changed files
with
289 additions
and
32 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
50 changes: 50 additions & 0 deletions
50
spock-core/src/main/java/org/spockframework/runtime/ErrorContext.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,50 @@ | ||
package org.spockframework.runtime; | ||
|
||
import org.spockframework.lang.ISpecificationContext; | ||
import org.spockframework.runtime.model.*; | ||
|
||
class ErrorContext implements IErrorContext { | ||
private final SpecInfo spec; | ||
private final FeatureInfo feature; | ||
private final IterationInfo iteration; | ||
private final BlockInfo block; | ||
|
||
private ErrorContext(SpecInfo spec, FeatureInfo feature, IterationInfo iteration, BlockInfo block) { | ||
this.spec = spec; | ||
this.feature = feature; | ||
this.iteration = iteration; | ||
this.block = block; | ||
} | ||
|
||
static ErrorContext from(ISpecificationContext context) { | ||
if (context.isSharedContext()) { | ||
return new ErrorContext(context.getCurrentSpec(), null, null, null); | ||
} | ||
return new ErrorContext( | ||
context.getCurrentSpec(), | ||
context.getCurrentFeature(), | ||
context.getCurrentIteration(), | ||
context.getCurrentBlock() | ||
); | ||
} | ||
|
||
@Override | ||
public SpecInfo getCurrentSpec() { | ||
return spec; | ||
} | ||
|
||
@Override | ||
public FeatureInfo getCurrentFeature() { | ||
return feature; | ||
} | ||
|
||
@Override | ||
public IterationInfo getCurrentIteration() { | ||
return iteration; | ||
} | ||
|
||
@Override | ||
public BlockInfo getCurrentBlock() { | ||
return block; | ||
} | ||
} |
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.