forked from shazam/fork
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from agoda-com/develop
merge develop to master
- Loading branch information
Showing
10 changed files
with
154 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ local.properties | |
|
||
# output files | ||
fork-output | ||
|
||
*/out |
13 changes: 13 additions & 0 deletions
13
fork-common-test-dex/app/src/androidTest/java/com/shazam/annotations/Inheritance.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,13 @@ | ||
package com.shazam.annotations; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Retention(RUNTIME) | ||
@Target({TYPE, METHOD}) | ||
public @interface Inheritance { | ||
} |
26 changes: 26 additions & 0 deletions
26
fork-common-test-dex/app/src/androidTest/java/com/shazam/forktest/TestA.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,26 @@ | ||
package com.shazam.forktest; | ||
|
||
import android.Manifest; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TestA { | ||
|
||
private final int a; | ||
private final int b; | ||
private final int res; | ||
|
||
public TestA(int a, int b, int res) { | ||
this.a = a; | ||
this.b = b; | ||
this.res = res; | ||
} | ||
|
||
@Test | ||
public void methodTest() { | ||
assertEquals(res, a + b); | ||
} | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
fork-common-test-dex/app/src/androidTest/java/com/shazam/forktest/TestB.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,11 @@ | ||
package com.shazam.forktest; | ||
|
||
import com.shazam.annotations.Inheritance; | ||
|
||
@Inheritance | ||
public class TestB extends TestA { | ||
public TestB() { | ||
super(2, 2, 4); | ||
} | ||
} | ||
|
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
52 changes: 52 additions & 0 deletions
52
fork-common/src/test/java/com/shazam/fork/suite/TestSuiteLoaderInheritanceTest.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,52 @@ | ||
package com.shazam.fork.suite; | ||
|
||
import com.shazam.fork.io.DexFileExtractor; | ||
import com.shazam.fork.model.TestCaseEvent; | ||
import com.shazam.fork.model.TestCaseEventFactory; | ||
import com.shazam.fork.stat.StatServiceLoader; | ||
import com.shazam.fork.stat.TestStatsLoader; | ||
import org.jf.dexlib.DexFile; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.Collection; | ||
|
||
import static com.shazam.fork.io.FakeDexFileExtractor.fakeDexFileExtractor; | ||
import static com.shazam.fork.io.Files.convertFileToDexFile; | ||
import static com.shazam.fork.suite.FakeTestClassMatcher.fakeTestClassMatcher; | ||
import static com.shazam.fork.suite.TestSuiteLoaderTestUtils.sameTestEventAs; | ||
import static com.shazam.shazamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
public class TestSuiteLoaderInheritanceTest { | ||
private static final File ANY_INSTRUMENTATION_APK_FILE = null; | ||
|
||
private final DexFileExtractor fakeDexFileExtractor = fakeDexFileExtractor().thatReturns(testDexFile()); | ||
private final TestClassMatcher fakeTestClassMatcher = fakeTestClassMatcher().thatAlwaysMatches(); | ||
private TestSuiteLoader testSuiteLoader; | ||
|
||
private DexFile testDexFile() { | ||
URL testDexResourceUrl = this.getClass().getResource("/tests.dex"); | ||
String testDexFile = testDexResourceUrl.getFile(); | ||
File file = new File(testDexFile); | ||
return convertFileToDexFile().apply(file); | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
testSuiteLoader = new TestSuiteLoader(ANY_INSTRUMENTATION_APK_FILE, fakeDexFileExtractor, fakeTestClassMatcher, | ||
"com.shazam.annotations.Inheritance", | ||
"",new TestCaseEventFactory(new TestStatsLoader(new StatServiceLoader("")))); | ||
} | ||
|
||
@Test | ||
public void testIncludeAnnotation() throws Exception { | ||
Collection<TestCaseEvent> events = testSuiteLoader.loadTestSuite(); | ||
assertThat(events.size(),is(1)); | ||
assertThat(events, hasItem(sameTestEventAs("methodTest", "com.shazam.forktest.TestB", false))); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
9 changes: 5 additions & 4 deletions
9
fork-runner/src/main/java/com/shazam/fork/batch/TestTaskQueueProvider.kt
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