Skip to content

Commit

Permalink
Added unit test, updated build script and ivy
Browse files Browse the repository at this point in the history
  • Loading branch information
cjayswal committed Sep 22, 2016
1 parent a391509 commit ada6e78
Show file tree
Hide file tree
Showing 28 changed files with 1,606 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="src" path="test/src"/>
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=QAFOSS&amp;ivyXmlPath=ivy.xml&amp;confs=*"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_75]"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/build/
/repository/
/.settings
/test-output/
37 changes: 34 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ For any inquiry or need additional information, please contact support-qaf@infos

<property name="bin.dir" value="${basedir}/bin" />
<property name="src.dir" value="${basedir}/src" />
<property name="test.dir" value="${basedir}/test" />
<property name="test.src.dir" value="${test.dir}/src" />
<property name="meta.dir" value="${basedir}/META-INF" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.6" />
Expand All @@ -45,6 +47,13 @@ For any inquiry or need additional information, please contact support-qaf@infos
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.classpath">
<fileset dir="${dist.dir}">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
<path refid="build.classpath" />
</path>

<!-- IVY -->
<target name="download-ivy" unless="skip.download">
Expand Down Expand Up @@ -86,7 +95,6 @@ For any inquiry or need additional information, please contact support-qaf@infos
<mkdir dir="${bin.dir}" />
<copy includeemptydirs="false" todir="${bin.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.ucls" />
<exclude name="**/*.java" />
</fileset>
</copy>
Expand Down Expand Up @@ -242,7 +250,30 @@ For any inquiry or need additional information, please contact support-qaf@infos
<artifacts pattern="${dist.dir}/[artifact].[ext]" />
</ivy:publish>
</target>

<target name="test" depends="make-jar">

<target name="test-compile" depends="init">
<taskdef classpathref="test.classpath" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" />

<echo level="info">--- test compile (start) ---</echo>
<iajc source="${source}" target="${target}" showweaveinfo="true" verbose="true" destdir="${bin.dir}" debug="false">
<inpath location="${src.dir}">
</inpath>
<sourceroots>
<pathelement location="${test.src.dir}" />
</sourceroots>
<classpath refid="test.classpath">
</classpath>
</iajc>
<echo level="info">--- test compile (finished) ---</echo>
</target>
<target name="test" depends="make-jar, test-compile">
<taskdef resource="testngtasks" classpathref="test.classpath"/>
<testng classpathref="test.classpath" workingDir="${test.dir}" outputDir="${test.dir}/test-results">
<classpath location="${bin.dir}" />
<xmlfileset dir="${test.dir}/config" includes="testrun_config.xml"/>
<sysproperty key="log4j.configuration" value="file:///${test.dir}/log4j.properties" />
<sysproperty key="outputDir" value="test-results" />

</testng>
</target>
</project>
8 changes: 4 additions & 4 deletions ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- hamcrest -->
<dependency org="org.hamcrest" name="hamcrest-core" rev="1.3" />

<dependency org="junit" name="junit" rev="4.11" />
<!-- <dependency org="junit" name="junit" rev="4.11" /> -->

<!-- jai -->
<dependency org="javax.media" name="jai-core" rev="1.1.3">
Expand All @@ -58,14 +58,14 @@
<dependency org="sshtools" name="j2ssh-core" rev="0.2.9" />

<!-- aspectj -->
<dependency org="org.aspectj" name="aspectjrt" rev="1.7.2">
<dependency org="org.aspectj" name="aspectjrt" rev="1.8.9">
<artifact name="aspectjrt" type="jar"></artifact>
</dependency>

<dependency org="org.aspectj" name="aspectjweaver" rev="1.7.2">
<dependency org="org.aspectj" name="aspectjweaver" rev="1.8.9">
<artifact name="aspectjweaver" type="jar"></artifact>
</dependency>
<dependency org="org.aspectj" name="aspectjtools" rev="1.7.2">
<dependency org="org.aspectj" name="aspectjtools" rev="1.8.9">
<artifact name="aspectjtools" type="jar"></artifact>
</dependency>

Expand Down
11 changes: 6 additions & 5 deletions src/com/qmetry/qaf/automation/cucumber/QAFCucumberFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private static void log(String message, MessageTypes type) {
com.qmetry.qaf.automation.util.Reporter.log(message, type);
}

private void logStepResult(Result result, MethodResult methodResult) {
protected void logStepResult(Result result, MethodResult methodResult) {
Match match = (Match) getTestBase().getContext().getObject(STEP_MATCH);
QAFTestBase testBase = getTestBase();
MethodInfo methodInfo = getMethodInfo();
Expand Down Expand Up @@ -306,6 +306,7 @@ private void logStepResult(Result result, MethodResult methodResult) {
stepCommandLog.setDuration(duration);

methodResult.getSeleniumLog().add(stepCommandLog);
testBase.claerAssertionsLog();

if (getSteps().isEmpty()) {
methodInfo.setDuration(System.currentTimeMillis() - methodInfo.getStartTime());
Expand All @@ -316,7 +317,6 @@ private void logStepResult(Result result, MethodResult methodResult) {
updateMetaInfo();// re-stamp suite status
// clean up
getTestBase().getContext().configurationAt(CUCUMBER_REPORT).clear();
testBase.claerAssertionsLog();
}

} else {
Expand Down Expand Up @@ -380,6 +380,7 @@ private String getTestName() {
}

private void init() {
getBundle().setProperty("cucumber.run.mode", "true");
getTestBase().getContext().setProperty(ApplicationProperties.JSON_REPORT_DIR.key, JSON_REPORT_DIR);
FileUtil.checkCreateDir(ApplicationProperties.JSON_REPORT_ROOT_DIR.getStringVal("test-results"));
FileUtil.checkCreateDir(JSON_REPORT_DIR);
Expand Down Expand Up @@ -485,7 +486,7 @@ private void updateOverview() {
}
}

private void writeMethodResult(MethodInfo methodInfo, MethodResult methodResult) {
protected void writeMethodResult(MethodInfo methodInfo, MethodResult methodResult) {

String dir = getTestResultDir() + "/" + getTestBase().getContext().getString(URI) + "/";

Expand Down Expand Up @@ -626,7 +627,7 @@ public void endOfScenarioLifeCycle(Scenario scenario) {
testBase.claerAssertionsLog();
}

private static MethodInfo getMethodInfo() {
protected static MethodInfo getMethodInfo() {
MethodInfo methodInfo = (MethodInfo) getTestBase().getContext().getObject(METHOD_INFO);
if (null == methodInfo) {
methodInfo = new MethodInfo();
Expand All @@ -644,7 +645,7 @@ private static void update(MethodInfo methodInfo, MethodResult methodResult) {
}
}

private static MethodResult getMethodResult() {
protected static MethodResult getMethodResult() {
MethodResult methodResult = (MethodResult) getTestBase().getContext().getObject(METHOD_RESULT);
if (null == methodResult) {
methodResult = new MethodResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import org.testng.internal.TestNGMethod;
import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.internal.thread.ThreadUtil;
import org.testng.xml.XmlTest;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static boolean matches(String def, String call) {
String origDef = def;
def = def.replaceAll(ParamType.getParamDefRegx(), ParamType.getParamValueRegx().replaceAll("\\\\", "\\\\\\\\"));
// System.out.println(def);
if (!StringMatcher.likeIgnoringCase("(((" + BDDKeyword.getAllKeyWords() + ")\\s)?" + def + ")").match(call)) {
if (!StringMatcher.likeIgnoringCase("(((" + BDDKeyword.getKeyWordRegEx() + ")\\s)?" + def + ")").match(call)) {
return false;
} else {
List<String[]> argsa = getArgsFromCall(origDef, call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.testng.annotations.DataProvider;

import com.qmetry.qaf.automation.core.ConfigurationManager;
import com.qmetry.qaf.automation.testng.DataProviderException;
import com.qmetry.qaf.automation.testng.dataprovider.DataProviderFactory;
import com.qmetry.qaf.automation.testng.dataprovider.QAFDataProvider.params;
import com.qmetry.qaf.automation.util.CSVUtil;
Expand Down Expand Up @@ -268,6 +269,11 @@ public static final Object[][] getDataFromProp(Method method) {
public static List<Object[]> getDataSetAsMap(String key) {
Configuration config = ConfigurationManager.getBundle().subset(key);
ArrayList<Object[]> dataset = new ArrayList<Object[]>();
if(config.isEmpty()){
logger.error("Missing data with key [" + key
+ "]. ");
throw new DataProviderException("Not test data found with key:" + key);
}
int size = config.getList(config.getKeys().next().toString()).size();
for (int i = 0; i < size; i++) {
Map<String, String> map = new LinkedHashMap<String, String>();
Expand Down
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/test-results/
45 changes: 45 additions & 0 deletions test/config/testrun_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<!-- QMetry Automation Framework provides a powerful and versatile platform
to author Automated Test Cases in Behavior Driven, Keyword Driven or Code
Driven approach Copyright 2016 Infostretch Corporation This program is free
software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or any later version. This program is distributed
in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
You should have received a copy of the GNU General Public License along with
this program in the name of LICENSE.txt in the root folder of the distribution.
If not, see https://opensource.org/licenses/gpl-3.0.html See the NOTICE.TXT
file in root folder of this source files distribution for additional information
regarding copyright ownership and licenses of other open source software
/ files used by QMetry Automation Framework. For any inquiry or need additional
information, please contact [email protected] -->

<suite name="QAF Tests" verbose="0">

<test name="Scenario">
<packages>
<package name="com.qmetry.qaf.automation.scenario" />
</packages>
</test>
<test name="TestStep">
<packages>
<package name="com.qmetry.qaf.automation.step" />
</packages>
</test>
<test name="Utils">
<packages>
<package name="com.qmetry.qaf.automation.utils" />
</packages>
</test>
<test name="TestData">
<packages>
<package name="com.qmetry.qaf.automation.data" />
</packages>
</test>

</suite>
80 changes: 80 additions & 0 deletions test/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#******************************************************************************************
# QMetry Automation Framework provides a powerful and versatile platform to author Test Cases in
# Behavior Driven, Keyword Driven or Code Driven approach
#
# Copyright 2016 Infostretch Corporation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# See the NOTICE file in root folder of distributed with this work for
# additional information regarding copyright ownership
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in the name of LICENSE.
#
# It is located at the root folder of the distribution.
# If not, see https://opensource.org/licenses/gpl-3.0.html
#
#******************************************************************************************
# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategory=INFO, CONSOLE


log4j.rootCategory=DEBUG, CONSOLE, LOGFILE
log4j.appender.console.Follow=true
#log4j.logger.com.qmetry.qaf=CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
#log4j.appender.CONSOLE.Follow=true

log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%c{1}] - %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=${outputDir}/isfw.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.Follow=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=[%t] %d{HH:mm:ss,SSS} %-5p [%c] %m%n
#%-4r [%t] %-5p %c %x - %m%n

log4j.logger.com.qmetry.qaf.automation.integration=resultUpdationLog

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.resultUpdationLog=org.apache.log4j.FileAppender
log4j.appender.resultUpdationLog.File=resultUpdation.log
log4j.appender.resultUpdationLog.Append=true
log4j.appender.resultUpdationLog.Threshold=INFO
log4j.appender.resultUpdationLog.layout=org.apache.log4j.PatternLayout
log4j.appender.resultUpdationLog.layout.ConversionPattern=%-6r [%t] %-5p %c %x - %m%n

log4j.additivity.com.qmetry.qaf.automation.step=false
log4j.logger.com.qmetry.qaf.automation.step=DEBUG, SCENARIOLOGFILE
log4j.appender.SCENARIOLOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.SCENARIOLOGFILE.File=${outputDir}/scenario.log
log4j.appender.SCENARIOLOGFILE.Append=true
log4j.appender.SCENARIOLOGFILE.Threshold=DEBUG
log4j.appender.SCENARIOLOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.SCENARIOLOGFILE.layout.ConversionPattern=%d{HH:mm:ss} %m%n

log4j.logger.ws_rest=DEBUG, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.file=${outputDir}/ws.log
log4j.appender.file.MaxFileSize=1GB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.conversionPattern=%d{[dd.MM.yyyy] [HH:mm:ss]} %p [%t] %c (%F:%L) - %m%n
26 changes: 26 additions & 0 deletions test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#*******************************************************************************
# QMetry Automation Framework provides a powerful and versatile platform to author
# Automated Test Cases in Behavior Driven, Keyword Driven or Code Driven approach
#
# Copyright 2016 Infostretch Corporation
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#
# You should have received a copy of the GNU General Public License along with this program in the name of LICENSE.txt in the root folder of the distribution. If not, see https://opensource.org/licenses/gpl-3.0.html
#
# See the NOTICE.TXT file in root folder of this source files distribution
# for additional information regarding copyright ownership and licenses
# of other open source software / files used by QMetry Automation Framework.
#
# For any inquiry or need additional information, please contact [email protected]
#******************************************************************************

env.resources=resources
resources.load.subdirs=1

Loading

0 comments on commit ada6e78

Please sign in to comment.