Skip to content

Commit

Permalink
Release 3.0.0-alpha1 (#16)
Browse files Browse the repository at this point in the history
* upgrade gradle and android plugin

* use implementation and api instead of compile

* migrate chimprunner and fork-reporter

* remove old implementation

* add includedAnnotation to config and gradle plugin task

* add includedAnnotation and excludedAnnotation to TestSuiteLoader

* implement convert from com.example.Test to Lcom/example/Test;

* implement exclude/include on TestSuiteLoader level

* fix compilation error

* add common pool strategy

* implement exclude/include annotations at TestSuiteLoader

* remove logger

* refactoring of TestSuiteLoader. add tests for parseAnnotation function

* fix TestSuiteLoader bug

* fix TestSuiteLoader

* [WIP] Execution chart + Sorting (#13)

* add teamcity client

* add fork sorting common module. add basic entities

* add fork-sorting-teamcity module. this module incapsulate teamcity client and mapping

* add Teamcity based sorting strategy

* add dependencies between modules

* add chart page

* move history manager and testexecution reporter to stat package

* return optional from test history manager

* fix summary printer injector

* cleanup properties

* use long timestamp instead of string format

* use timestamp instead of string

* change format of report

* rework loader

* rename package

* rework teamcity loader

* remove test.yaml

* temp solution

* fix compile time errors

* add testMetrics getter

* remove dependency to fork-stat-teamcity from fork-runner

* move teamcity client to fork-stat-teamcity

* add queue provider

* use TestCaseEventFactory instead of static factory methods

* remove testHistoryManager

* remove unused AuthConfig

* removed unused function

* fix chart

* add info about idling

* remove logs

* fix comments

* change tick format

* experiment with PriorityBlockingQueue

* fix codeformat

* alpha1 release
  • Loading branch information
tagantroy authored Dec 20, 2017
1 parent dda45bc commit e3981c4
Show file tree
Hide file tree
Showing 102 changed files with 2,492 additions and 157 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/

task wrapper(type: Wrapper) {
gradleVersion = '4.1'
gradleVersion = '4.3'
}

ext.sourceCompatibility = JavaVersion.VERSION_1_8
ext.targetCompatibility = JavaVersion.VERSION_1_8

ext.androidPlugin = '3.0.0-beta5'
ext.androidPlugin = '3.0.0'

def repos = {
mavenLocal()
Expand Down
12 changes: 6 additions & 6 deletions chimprunner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'application'
apply from: '../build-scripts/gradle-mvn-push.gradle'

Expand All @@ -18,18 +18,18 @@ sourceCompatibility = rootProject.sourceCompatibility
targetCompatibility = rootProject.sourceCompatibility

dependencies {
compile project(':fork-common')
compile(
api project(':fork-common')
implementation(
"org.slf4j:slf4j-log4j12:$SLF4J_VERSION",
"com.beust:jcommander:$JCOMMANDER_VERSION",
"au.com.bytecode:opencsv:2.4"
)

testCompile("org.hamcrest:hamcrest-all:$HAMCREST_VERSION")
testCompile("junit:junit:$JUNIT_VERSION") {
testImplementation("org.hamcrest:hamcrest-all:$HAMCREST_VERSION")
testImplementation("junit:junit:$JUNIT_VERSION") {
exclude module:'hamcrest-core'
}
testCompile(
testImplementation(
"org.jmock:jmock:$JMOCK_VERSION",
"org.jmock:jmock-junit4:$JMOCK_VERSION")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.shazam.chimprunner.injector.model;

import com.shazam.fork.model.TestCaseEventFactory;

import static com.shazam.chimprunner.injector.stat.TestStatLoaderInjector.testStatsLoader;

public class TestCaseEventFactoryInjector {
public static TestCaseEventFactory testCaseEventFactory(){
return new TestCaseEventFactory(testStatsLoader());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.shazam.chimprunner.injector.stat;

import com.shazam.fork.stat.StatServiceLoader;

public class StatServiceLoaderInjector {

private static StatServiceLoader INSTANCE = null;

public static synchronized StatServiceLoader statServiceLoader() {
if (INSTANCE == null) {
INSTANCE = new StatServiceLoader("");
}
return INSTANCE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.shazam.chimprunner.injector.stat;

import com.shazam.fork.stat.TestStatsLoader;

import static com.shazam.chimprunner.injector.stat.StatServiceLoaderInjector.statServiceLoader;

public class TestStatLoaderInjector {
private static final TestStatsLoader INSTANCE = new TestStatsLoader(statServiceLoader());

public static TestStatsLoader testStatsLoader() {
return INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import static com.shazam.chimprunner.injector.ConfigurationInjector.configuration;
import static com.shazam.chimprunner.injector.io.DexFileExtractorInjector.dexFileExtractor;
import static com.shazam.chimprunner.injector.model.TestCaseEventFactoryInjector.testCaseEventFactory;
import static com.shazam.chimprunner.injector.stat.TestStatLoaderInjector.testStatsLoader;
import static com.shazam.chimprunner.injector.suite.TestClassMatcherInjector.testClassMatcher;

public class TestSuiteLoaderInjector {
Expand All @@ -22,6 +24,9 @@ private TestSuiteLoaderInjector() {
}

public static TestSuiteLoader testSuiteLoader() {
return new TestSuiteLoader(configuration().getInstrumentationApk(), dexFileExtractor(), testClassMatcher());
return new TestSuiteLoader(configuration().getInstrumentationApk(),
dexFileExtractor(), testClassMatcher(),
"", "",
testCaseEventFactory());
}
}
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 CustomTestAnnotation1 {
}
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 CustomTestAnnotation2 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.shazam.forktest;

import org.junit.Ignore;
import org.junit.Test;
import com.shazam.annotations.CustomTestAnnotation1;

import static org.junit.Assert.assertEquals;

@CustomTestAnnotation1
public class CustomTestAnnotation1ClassTest {

@Test
public void methodOfAnCustomTestAnnotation1TestClass() {
assertEquals(4, 2 + 2);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.shazam.forktest;

import org.junit.Ignore;
import org.junit.Test;
import com.shazam.annotations.CustomTestAnnotation2;

import static org.junit.Assert.assertEquals;

@CustomTestAnnotation2
public class CustomTestAnnotation2ClassTest {

@Test
public void methodOfAnCustomTestAnnotation2TestClass() {
assertEquals(4, 2 + 2);
}
}

2 changes: 1 addition & 1 deletion fork-common-test-dex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0-beta5"
classpath "com.android.tools.build:gradle:3.0.0"


// NOTE: Do not place your application dependencies here; they belong
Expand Down
23 changes: 12 additions & 11 deletions fork-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

apply plugin: 'java'
apply plugin: 'java-library'
apply from: '../build-scripts/gradle-mvn-push.gradle'

//noinspection GroovyUnusedAssignment
Expand All @@ -17,26 +17,27 @@ sourceCompatibility = rootProject.sourceCompatibility
targetCompatibility = rootProject.sourceCompatibility

dependencies {
compile project(':fork-client')
compile(
"com.google.code.findbugs:jsr305:3.0.1",
api project(':fork-client')
api project(':fork-stat-common')
api "com.google.code.findbugs:jsr305:3.0.1"
api "com.android.tools.ddms:ddmlib:25.1.0"
api "commons-io:commons-io:2.5"
api "org.apache.commons:commons-lang3:3.4"
api "com.github.spullara.mustache.java:compiler:0.8.0"
api "com.google.code.gson:gson:$GSON_VERSION"
implementation(
"com.google.guava:guava:19.0",
"com.android.tools.ddms:ddmlib:25.1.0",
"commons-io:commons-io:2.5",
"org.apache.commons:commons-lang3:3.4",
"com.github.spullara.mustache.java:compiler:0.8.0",
"com.google.code.gson:gson:$GSON_VERSION",
"org.slf4j:slf4j-log4j12:$SLF4J_VERSION",
"org.smali:dexlib:1.4.2",
"com.shazam:axmlparser:1.0"
)

testCompile(
testImplementation(
"org.hamcrest:hamcrest-all:$HAMCREST_VERSION",
"org.jmock:jmock:$JMOCK_VERSION",
"org.jmock:jmock-junit4:$JMOCK_VERSION",
"com.shazam:shazamcrest:0.11")
testCompile("junit:junit:$JUNIT_VERSION") {
testImplementation("junit:junit:$JUNIT_VERSION") {
exclude module:'hamcrest-core'
}
}
Expand Down
22 changes: 8 additions & 14 deletions fork-common/src/main/java/com/shazam/fork/model/TestCaseEvent.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.shazam.fork.model;

import com.android.ddmlib.testrunner.TestIdentifier;
import com.agoda.fork.stat.TestMetric;
import com.google.common.base.Objects;

import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString;
import static org.apache.commons.lang3.builder.ToStringStyle.SIMPLE_STYLE;

Expand All @@ -20,21 +16,15 @@ public class TestCaseEvent {
private final boolean isIgnored;
private final List<String> permissionsToRevoke;
private final Map<String, String> properties;
private final TestMetric testMetric;

private TestCaseEvent(String testMethod, String testClass, boolean isIgnored, List<String> permissionsToRevoke, Map<String, String> properties) {
TestCaseEvent(String testMethod, String testClass, boolean isIgnored, List<String> permissionsToRevoke, Map<String, String> properties, TestMetric testMetric) {
this.testMethod = testMethod;
this.testClass = testClass;
this.isIgnored = isIgnored;
this.permissionsToRevoke = permissionsToRevoke;
this.properties = properties;
}

public static TestCaseEvent newTestCase(String testMethod, String testClass, boolean isIgnored, List<String> permissionsToRevoke, Map<String, String> properties) {
return new TestCaseEvent(testMethod, testClass, isIgnored, permissionsToRevoke, properties);
}

public static TestCaseEvent newTestCase(@Nonnull TestIdentifier testIdentifier) {
return new TestCaseEvent(testIdentifier.getTestName(), testIdentifier.getClassName(), false, emptyList(), emptyMap());
this.testMetric = testMetric;
}

public String getTestMethod() {
Expand All @@ -57,6 +47,10 @@ public Map<String, String> getProperties() {
return properties;
}

public TestMetric getTestMetric() {
return testMetric;
}

@Override
public int hashCode() {
return Objects.hashCode(this.testMethod, this.testClass);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shazam.fork.model;

import com.android.ddmlib.testrunner.TestIdentifier;
import com.shazam.fork.stat.TestStatsLoader;

import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class TestCaseEventFactory {

private final TestStatsLoader statsLoader;

public TestCaseEventFactory(TestStatsLoader statsLoader) {
this.statsLoader = statsLoader;
}

public TestCaseEvent newTestCase(@Nonnull TestIdentifier testIdentifier) {
return new TestCaseEvent(testIdentifier.getTestName(),
testIdentifier.getClassName(),
false,
Collections.emptyList(),
Collections.emptyMap(),
statsLoader.findMetric(testIdentifier.getClassName(), testIdentifier.getClassName()));
}

public TestCaseEvent newTestCase(String testMethod, String testClass, boolean isIgnored, List<String> permissionsToRevoke, Map<String, String> properties) {
return new TestCaseEvent(testMethod, testClass, isIgnored, permissionsToRevoke, properties, statsLoader.findMetric(testClass, testMethod));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.shazam.fork.stat;

import com.agoda.fork.stat.StatLoader;
import com.agoda.fork.stat.StatLoaderProvider;
import com.agoda.fork.stat.TestHistory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

public class StatServiceLoader {

private static final Logger logger = LoggerFactory.getLogger(StatServiceLoader.class);

private final String path;

public StatServiceLoader(String path) {
this.path = path;
}

public List<TestHistory> load() {
return StreamSupport.stream(ServiceLoader.load(StatLoaderProvider.class).spliterator(), true)
.flatMap(loader -> {
List<TestHistory> histories = new ArrayList<>();
try {
histories.addAll(loader.create(path).loadHistory());
} catch (FileNotFoundException e) {
logger.error("can't load history", e);
}
return histories.stream();
})
.collect(Collectors.toList());
}
}
Loading

0 comments on commit e3981c4

Please sign in to comment.