Skip to content

Commit

Permalink
Merge pull request NetEase#21 from andrewleo/master
Browse files Browse the repository at this point in the history
add self-test and build automated testing process
  • Loading branch information
sephinroth committed Aug 29, 2013
2 parents 34f633b + 43ce1d2 commit cf8ccbb
Show file tree
Hide file tree
Showing 17 changed files with 783 additions and 29 deletions.
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Dagger - a light, robust Web UI autotest framework

Dagger is a light, robust Web UI autotest framework based on [Selenium](http://seleniumhq.org/) and [TestNg](http://testng.org/doc/index.html).(中文介绍参见[这里](https://github.com/NetEase/Dagger/wiki/Dagger)
Dagger is a light, robust Web UI autotest framework based on [Selenium](http://seleniumhq.org/) and [TestNG](http://testng.org/doc/index.html).(中文介绍参见[这里](https://github.com/NetEase/Dagger/wiki/Dagger)

> Dagger is an automation framework first, it provides APIs to control browsers;
>
Expand All @@ -11,33 +11,35 @@ Dagger is a light, robust Web UI autotest framework based on [Selenium](http://s
* Wiki: <https://github.com/NetEase/Dagger/wiki>
* Issues: <https://github.com/NetEase/Dagger/issues>
* Javadoc: <http://netease.github.com/Dagger>
* Tags: Selenium, TestNg, autotest
* Tags: Selenium, TestNG, autotest

## Features

* Easy to learn while only less then 20 APIs altogether, see [this](http://netease.github.com/Dagger/classcom_1_1netease_1_1dagger_1_1_browser_emulator.html).
* Providing a quickstart, see [this](https://github.com/NetEase/Dagger/wiki/Quick-Start).
* High speed with parallel mode which is indeed TestNg's feature, see [this](https://github.com/NetEase/Dagger/wiki/Parallel-Mode)
* Providing a quick start, see [this](https://github.com/NetEase/Dagger/wiki/Quick-Start).
* High speed with parallel mode which is indeed TestNG's feature, see [this](https://github.com/NetEase/Dagger/wiki/Parallel-Mode)
* High stability with a trick on TestNg to retry failed/skipped testcases automatically, see [this](https://github.com/NetEase/Dagger/wiki/Retry-Failed-Or-Skipped-Testcases).
* Using Chrome as default browser which is much more quick and stable than Firefox and IE.
* Using Chrome as default browser which is much quicker and more stable than both Firefox and IE.
* Firefox and IE are also supported.
* Capture screenshot automatically when testcase failed.
* Capture screenshot automatically when testcase fails.

## Coming soon
## Coming Soon

* Integrating Flex/Flash automation.
* Integration with Flex/Flash automation.

## How to use Dagger
## How to Use

Dagger is quite suitable for a small group to kick off Web UI autotest, for this case, just checkout Dagger with Eclipse and write testcases within it.
Dagger is quite suitable for a small group to kick off Web UI autotest. For this case, just checkout Dagger with Eclipse and write testcases with it.

Already have an autotest framework? Please build Dagger into a .jar file to use, see [this](https://github.com/NetEase/Dagger/wiki/FAQ)
Already have an autotest framework? Please build Dagger into a .jar file before use, see [this](https://github.com/NetEase/Dagger/wiki/FAQ).
But first, you should download the [selenium-server-standalone-2.33.0.jar](https://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar), or the latest one from [here](https://code.google.com/p/selenium/downloads/list).

## Contributors

* NetEase, Inc.
* chenDoInG

## How to contribute
## How to Contribute

You are welcome to contribute to Dagger as follow

Expand All @@ -47,7 +49,12 @@ You are welcome to contribute to Dagger as follow
* commit new feature
* add testcase/demo

And it's *NOT* recommended to submit pull request directly to Dagger's `master` branch
Meanwhile you'd better follow the rules below

* It's *NOT* recommended to submit a pull request directly to Dagger's `master` branch. `develop` branch is more appropriate
* Follow common Java coding conventions
* Put all Java class files under *com.netease* package
* Add the following [license](#license) in each Java class file

## License

Expand Down
41 changes: 32 additions & 9 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

<path id="cpath">
<fileset dir="lib">
<include name="testng-re-html.jar"/>
<include name="testng-re-html.jar" />
<include name="log4j-1.2.16.jar" />
<include name="jxl-2.6.12.jar" />
</fileset>
<fileset dir="lib">
<include name="selenium-server-standalone-2.29.0.jar" />
<include name="selenium-server-standalone-2.33.0.jar" />
</fileset>
</path>

Expand All @@ -21,31 +22,53 @@
<target name="compile">
<delete dir="bin" />
<mkdir dir="bin" />
<javac source="1.6" target="1.6" compiler="org.eclipse.jdt.core.JDTCompilerAdapter" destdir="bin" classpathref="cpath" srcdir="src" debug="true" encoding="UTF8">
<javac source="1.6" target="1.6" destdir="bin" classpathref="cpath"
srcdir="src" debug="true" encoding="UTF8" includeAntRuntime="false">
</javac>
<copy file="src/log4j.properties" tofile="bin/log4j.properties" />
</target>

<target name="demo" depends="compile">
<delete dir="test-output" />
<mkdir dir="test-output" />
<testng outputDir="test-output" classpathref="runpath" >
<delete dir="test-output/demo" />
<mkdir dir="test-output/demo" />
<testng outputDir="test-output/demo" classpathref="runpath">
<xmlfileset dir="test-xml" includes="demo.xml" />
</testng>
</target>

<target name="jar" depends="compile">
<delete dir="build" />
<mkdir dir="build" />
<jar destfile="build/dagger-1.0.jar" basedir="bin" excludes="**/demo/">
</jar>
</target>

<target name="jar-src">
<delete dir="build" />
<mkdir dir="build" />
<jar destfile="build/dagger-1.0-src.jar" basedir="src" excludes="**/demo/">
</jar>
</target>

</project>
<path id="runpath">
<pathelement location="bin" />
<path refid="cpath" />
</path>

<property name="configFile" value="prop.properties" />
<!-- 采用Ant正则表达式的替换方式,修改浏览器 -->
<target name="edit_browser" depends="compile">
<replaceregexp file="${configFile}" match="^BrowserCoreType(.*)"
replace="BrowserCoreType=${BrowserCoreType}" byline="true" />
</target>

<!-- Dagger Self Test -->
<target name="self-test" depends="edit_browser">
<delete dir="test-output/self-test" />
<mkdir dir="test-output/self-test" />
<testng outputDir="test-output/self-test" classpathref="runpath">
<xmlfileset dir="test-xml" includes="self-test.xml" />
</testng>
</target>

</project>
1 change: 1 addition & 0 deletions src/com/netease/dagger/BrowserEmulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

/**
* BrowserEmulator is based on Selenium2 and adds some enhancements
* @author ChenKan
*/
public class BrowserEmulator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.chendoing.datadriver;
package com.netease.datadriver;

import java.io.FileInputStream;
import java.io.InputStream;
Expand All @@ -20,7 +20,6 @@
* @ClassName: ExcelDataProvider
* @Description: TODO(读取Excel数据)
* @author chenDoInG
* @date 2013-8-13 上午9:21:21
*/
public class ExcelDataProvider implements Iterator<Object[]> {

Expand Down
14 changes: 9 additions & 5 deletions src/com/netease/demo/GoogleSearchWithDataDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.chendoing.datadriver.ExcelDataProvider;
import com.netease.dagger.BrowserEmulator;

import com.netease.datadriver.ExcelDataProvider;
/**
*
* @author Chenkan
*
*/
public class GoogleSearchWithDataDriver {

BrowserEmulator browserEmulator;

@BeforeClass
public void setUp() throws Exception{
public void setUp() throws Exception {
browserEmulator = new BrowserEmulator();
}
@Test(dataProvider = "dp" )
Expand All @@ -29,11 +33,11 @@ public void search(Map<String,String> data) {
}

@AfterClass(alwaysRun = true)
public void tearDown(){
public void tearDown() {
browserEmulator.quit();
}
@DataProvider(name = "dp")
public Iterator<Object[]> dataFortestMethod(Method method) throws IOException{
public Iterator<Object[]> dataFortestMethod(Method method) throws IOException {
return new ExcelDataProvider(this.getClass().getName(),method.getName());
}

Expand Down
3 changes: 3 additions & 0 deletions src/com/netease/imagecheck/ImageContrast.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* ImageContrast changes image from RGB to LAB and make comparison
* @author LingFei
*/
@SuppressWarnings("restriction")
public class ImageContrast {
Expand Down Expand Up @@ -137,6 +138,7 @@ public static boolean contrastImages(String sampleImagePath, String actualImageP

/**
* RGB color space
* @author LingFei
*/
public static class ColorLAB {
public double l;
Expand All @@ -146,6 +148,7 @@ public static class ColorLAB {

/**
* XYZ color space
* @author LingFei
*/
public static class ColorXYZ {
public double x;
Expand Down
1 change: 1 addition & 0 deletions src/com/netease/imagecheck/ImageProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/**
* ImageProcess contains APIs for screen shot and image process
* @author LingFei
*/
public class ImageProcess {

Expand Down
48 changes: 48 additions & 0 deletions src/com/netease/test/ClickOperations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.netease.test;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.netease.dagger.BrowserEmulator;

/**
* click的一系列测试
* @author WeiYating
*/
public class ClickOperations {

BrowserEmulator be;
String input = "hello";

@BeforeClass
public void doBeforeClass() {
be = new BrowserEmulator();
CommonFunction.openCaptain(be);
}

@Test
public void clickOperations() {
CommonFunction.clickOperations(be);
}

@Test(dependsOnMethods = "clickOperations")
public void clickButton() {
CommonFunction.clickButton(be);
}

@Test(dependsOnMethods = "clickButton")
public void clickLink() {
CommonFunction.clickLink(be);
}

@Test(dependsOnMethods = "clickLink")
public void submitForm() {
CommonFunction.submitForm(be, input);
}

@AfterClass(alwaysRun = true)
public void doAfterClass() {
be.quit();
}
}
Loading

0 comments on commit cf8ccbb

Please sign in to comment.