Merge pull request #519 from XiangRongLin/better_logging_error_handling
Better logging, error handling, doc for mock tests
This commit is contained in:
commit
a28e0226c5
|
@ -32,7 +32,9 @@ jobs:
|
|||
- name: Build and run Tests
|
||||
run: |
|
||||
if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
|
||||
echo running with real downloader
|
||||
./gradlew check --stacktrace -Ddownloader=REAL
|
||||
else
|
||||
echo running with mock downloader
|
||||
./gradlew check --stacktrace -Ddownloader=MOCK
|
||||
fi
|
||||
|
|
|
@ -27,8 +27,9 @@ class MockDownloader extends Downloader {
|
|||
public MockDownloader(@Nonnull String path) throws IOException {
|
||||
this.path = path;
|
||||
this.mocks = new HashMap<>();
|
||||
File folder = new File(path);
|
||||
for (File file : folder.listFiles()) {
|
||||
final File[] files = new File(path).listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.getName().startsWith(RecordingDownloader.FILE_NAME_PREFIX)) {
|
||||
final FileReader reader = new FileReader(file);
|
||||
final TestRequestResponse response = new GsonBuilder()
|
||||
|
@ -39,6 +40,7 @@ class MockDownloader extends Downloader {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response execute(@Nonnull Request request) {
|
||||
|
|
|
@ -27,6 +27,10 @@ import javax.annotation.Nonnull;
|
|||
* The files <b>must</b> be created on the local dev environment
|
||||
* and recreated when the requests made by a test class change.
|
||||
* </p>
|
||||
* <p>
|
||||
* Run the test class as a whole and not each test separately.
|
||||
* Make sure the requests made by a class are unique.
|
||||
* </p>
|
||||
*/
|
||||
class RecordingDownloader extends Downloader {
|
||||
|
||||
|
|
Loading…
Reference in New Issue