Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d2c949d
Add ant colony skeleton
Jan 30, 2020
d37dc7d
Add ant logger
Jan 30, 2020
f5c7e9c
First steps to implement ant colony algorithm
pjottr75 Feb 20, 2020
b2de140
Improved ACO
Feb 20, 2020
d27c5f2
Improved ACO during meeting with leon
Feb 21, 2020
ff84dcb
Merge branch 'github-master'
Feb 21, 2020
f84a32c
First implementation of changes after coordinating with gordon
Feb 24, 2020
91befaf
Finished implementing ACO and changes after agreeing with Prof. Frase…
Feb 28, 2020
2480eed
Minor Change, Changed deposit amount to global parameter for the enti…
Feb 28, 2020
30eea73
Fixed AntStatsLogger
Mar 3, 2020
9d7929b
Fixed running MATE on windows by Leon
Mar 10, 2020
fe1ce83
Fixed exiting loop and added temporary debugging comments
pjottr75 Mar 16, 2020
a17e349
Merge branch 'master' of https://www.github.com/mate-android-testing/…
Mar 21, 2020
a4d3526
Latest Changes, updated Genetic fitting to Ant
Apr 7, 2020
5789989
Latest Changes, finalizing functionality AntColony, RandomWalk added …
Jul 16, 2020
3188649
Updated logging in RandomExploration and AntColony, Added logging for…
Jul 26, 2020
bc2dba9
Fixed logging for Genetic Algorithm
Jul 30, 2020
b57cbca
Added logging of target line and fixed an error in Logging for GA
Aug 6, 2020
750c8cc
Fixed logging to be processable by RStudio, added "", removed spaces
Aug 22, 2020
92a987c
Fixed logging in ACO, missing column value if run unsuccessful;
Aug 24, 2020
786c9dd
Added timeout after 200 Test Cases for genetic algorithm
Sep 2, 2020
2c1181f
Fixed genetic algorithm timeout and adapted logging accordingly
Sep 9, 2020
50de166
Fixed problem with genetic algorithm logging where double successful …
Sep 9, 2020
442a915
Fixed a copy paste error resulting in a wrong log write
Sep 15, 2020
2765858
Modified Genetic Algorithm to stop after finding a successful TestCase,
Sep 18, 2020
cc28bf8
Removed unnecessary code,
Sep 22, 2020
dac0f4d
Set ACO parameters to Condition 2 (ActionTypeInTransition = false, Ra…
Oct 9, 2020
bc05672
Set ACO parameters to Condition 3 (ActionTypeInTransition = true, Ran…
Oct 14, 2020
35f5a2f
Set ACO parameters to Condition 4 (ActionTypeInTransition = true, Ran…
Oct 21, 2020
f3e12b1
Set ACO parameters to new Condition 2 (ActionTypeInTransition = true,…
Nov 8, 2020
93acd9b
Set ACO parameters to new Condition 3 (ActionTypeInTransition = false…
Nov 16, 2020
d62aab2
Set ACO parameters to new Condition 4 (ActionTypeInTransition = false…
Nov 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ gradle-app.setting

## Local properties
local.properties
ant.log
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ task checkstyle(type: Checkstyle) {
}

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "org.mate"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -97,7 +97,7 @@ android {

dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
implementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
implementation 'com.android.support.test:runner:1.0.2'
}
20 changes: 20 additions & 0 deletions app/src/androidTest/java/org/mate/ExecuteMATEAntColony.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.mate;

import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class ExecuteMATEAntColony {


@Test
public void useAppContext() throws Exception {

MATE.log_acc("Starting Ant Colony Exploration...");

MATE mate = new MATE();
mate.testApp("AntColonyExploration");
}
}
57 changes: 23 additions & 34 deletions app/src/main/java/org/mate/MATE.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;

import org.mate.exploration.ant.AntColony;
import org.mate.exploration.genetic.algorithm.RandomSearch;
import org.mate.exploration.genetic.fitness.BranchDistanceFitnessFunction;
import org.mate.exploration.genetic.fitness.BranchDistanceFitnessFunctionMultiObjective;
Expand Down Expand Up @@ -49,6 +50,8 @@
import org.mate.exploration.genetic.fitness.TestLengthFitnessFunction;
import org.mate.exploration.genetic.crossover.UniformSuiteCrossoverFunction;
import org.mate.exploration.genetic.termination.NeverTerminationCondition;
import org.mate.exploration.genetic.termination.TargetLineCoveredTerminationCondition;
import org.mate.exploration.genetic.fitness.LineCoveredPercentageFitnessFunction;
import org.mate.exploration.heuristical.HeuristicExploration;
import org.mate.exploration.heuristical.RandomExploration;
import org.mate.interaction.DeviceMgr;
Expand Down Expand Up @@ -251,6 +254,16 @@ public Void call() throws Exception {
.withTerminationCondition(IterTerminationCondition.TERMINATION_CONDITION_ID)
.build();
nsga.run();
} else if (explorationStrategy.equals("AntColonyExploration")) {
uiAbstractionLayer = new UIAbstractionLayer(deviceMgr, packageName);

AntColony antColony = new AntColony();
antColony.run();

if (Properties.STORE_COVERAGE()) {
Registry.getEnvironmentManager().storeCoverageData(antColony, null);
MATE.log_acc("Total coverage: " + Registry.getEnvironmentManager().getCombinedCoverage());
}
} else if (explorationStrategy.equals("PrimitiveStandardGeneticAlgorithm")) {
uiAbstractionLayer = new UIAbstractionLayer(deviceMgr, packageName);
MATE.log_acc("Activities");
Expand Down Expand Up @@ -286,42 +299,25 @@ public Void call() throws Exception {
}
} else if (explorationStrategy.equals("StandardGeneticAlgorithm")) {
uiAbstractionLayer = new UIAbstractionLayer(deviceMgr, packageName);
MATE.log_acc("Activities");
for (String s : Registry.getEnvironmentManager().getActivityNames()) {
MATE.log_acc("\t" + s);
}

if (Properties.COVERAGE() == Coverage.BRANCH_COVERAGE) {
// init the CFG
boolean isInit = Registry.getEnvironmentManager().initCFG();

if (!isInit) {
MATE.log("Couldn't initialise CFG! Aborting.");
throw new IllegalStateException("Graph initialisation failed!");
}
}

final IGeneticAlgorithm<TestCase> genericGA = new GeneticAlgorithmBuilder()
.withAlgorithm(StandardGeneticAlgorithm.ALGORITHM_NAME)
.withChromosomeFactory(AndroidRandomChromosomeFactory.CHROMOSOME_FACTORY_ID)
.withSelectionFunction(FitnessProportionateSelectionFunction.SELECTION_FUNCTION_ID)
.withCrossoverFunction(TestCaseMergeCrossOverFunction.CROSSOVER_FUNCTION_ID)
.withMutationFunction(CutPointMutationFunction.MUTATION_FUNCTION_ID)
.withFitnessFunction(BranchDistanceFitnessFunction.FITNESS_FUNCTION_ID)
.withTerminationCondition(NeverTerminationCondition.TERMINATION_CONDITION_ID)
.withPopulationSize(50)
.withBigPopulationSize(100)
.withFitnessFunction(LineCoveredPercentageFitnessFunction.FITNESS_FUNCTION_ID,
Properties.TARGET_LINE())
.withTerminationCondition(TargetLineCoveredTerminationCondition.TERMINATION_CONDITION_ID)
.withPopulationSize(20)
.withBigPopulationSize(40)
.withMaxNumEvents(50)
.withPMutate(0.3)
.withPCrossover(0.7)
.build();
TimeoutRun.timeoutRun(new Callable<Void>() {
@Override
public Void call() throws Exception {
genericGA.run();
return null;
}
}, MATE.TIME_OUT);

TargetLineCoveredTerminationCondition.INSTANCE.setGeneticAlgorithm(genericGA);
genericGA.run();

if (Properties.STORE_COVERAGE()) {
if (Properties.COVERAGE() == Coverage.BRANCH_COVERAGE) {
Expand Down Expand Up @@ -398,15 +394,8 @@ public Void call() throws Exception {
MATE.log_acc("\t" + s);
}

final RandomExploration randomExploration = new RandomExploration(50);

TimeoutRun.timeoutRun(new Callable<Void>() {
@Override
public Void call() throws Exception {
randomExploration.run();
return null;
}
}, MATE.TIME_OUT);
final RandomExploration randomExploration = new RandomExploration(Properties.STORE_COVERAGE(), true, 50);
randomExploration.run();

if (Properties.STORE_COVERAGE()) {
Registry.getEnvironmentManager().storeCoverageData(randomExploration, null);
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/mate/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public static Coverage COVERAGE() {
return propertyOr(Coverage.LINE_COVERAGE);
}

public static String TARGET_LINE() {
return propertyOr(null);
}



// Primitive actions or widget based actions?
Expand Down
Loading