File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 3232 - name : Build and run Tests
3333 run : |
3434 if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
35+ echo running with real downloader
3536 ./gradlew check --stacktrace -Ddownloader=REAL
3637 else
38+ echo running with mock downloader
3739 ./gradlew check --stacktrace -Ddownloader=MOCK
3840 fi
Original file line number Diff line number Diff line change @@ -27,15 +27,17 @@ class MockDownloader extends Downloader {
2727 public MockDownloader (@ Nonnull String path ) throws IOException {
2828 this .path = path ;
2929 this .mocks = new HashMap <>();
30- File folder = new File (path );
31- for (File file : folder .listFiles ()) {
32- if (file .getName ().startsWith (RecordingDownloader .FILE_NAME_PREFIX )) {
33- final FileReader reader = new FileReader (file );
34- final TestRequestResponse response = new GsonBuilder ()
35- .create ()
36- .fromJson (reader , TestRequestResponse .class );
37- reader .close ();
38- mocks .put (response .getRequest (), response .getResponse ());
30+ final File [] files = new File (path ).listFiles ();
31+ if (files != null ) {
32+ for (File file : files ) {
33+ if (file .getName ().startsWith (RecordingDownloader .FILE_NAME_PREFIX )) {
34+ final FileReader reader = new FileReader (file );
35+ final TestRequestResponse response = new GsonBuilder ()
36+ .create ()
37+ .fromJson (reader , TestRequestResponse .class );
38+ reader .close ();
39+ mocks .put (response .getRequest (), response .getResponse ());
40+ }
3941 }
4042 }
4143 }
Original file line number Diff line number Diff line change 2727 * The files <b>must</b> be created on the local dev environment
2828 * and recreated when the requests made by a test class change.
2929 * </p>
30+ * <p>
31+ * Run the test class as a whole and not each test separately.
32+ * Make sure the requests made by a class are unique.
33+ * </p>
3034 */
3135class RecordingDownloader extends Downloader {
3236
You can’t perform that action at this time.
0 commit comments