@mSolo
2015-04-16T11:12:05.000000Z
字数 5323
阅读 1657
Android 持续集成 TDD CI
./gradlew
| Target | Description |
|---|---|
| build | Assembles and tests this project |
| clean | Deletes the build directory |
| tasks | Displays the tasks runnable from root project x (some of the displayed tasks may belong to subprojects) |
| installDebug | Installs the Debug build |
| installDebugTest | Installs the Test build for the Debug build |
| connectedAndroidTest | Installs and runs the tests for Build debug on connected devices |
| uninstallDebug | Uninstalls the Debug build |
$ mkdir AndroidApplicationTestingGuide$ cd AndroidApplicationTestingGuide$ git init$ cp -a <path/to/original>/AndroidApplicationTestingGuide/$ gradlew clean$ rm local.properties$ git add .$ git commit -m "Initial commit"
$ java -jar ~/jenkins/jenkins-1.592.war$ java -jar fitnesse.jar -p 8900
创建 TemperatureConverterTests subwiki
Static: This is a normal Wiki page
Suite: This is a page containing other tests composing a suite
Test: This is a page that contains tests
public class TemperatureConverterCelsiusToFahrenheitFixture {private double celsius;public void setCelsius(double celsius) {this.celsius = celsius;}public String fahrenheit() throws Exception {try {double fahrenheit = TemperatureConverter.celsiusToFahrenheit(celsius);return String.valueOf(fahrenheit);} catch (RuntimeException e) {return e.getLocalizedMessage();}}}
$ java -jar /lib/fitnesse.jar -p 8900testCompile 'com.github.bernerbits:givwenzen:1.0.6.1'示例
__EXCEPTION__:org.givwenzen.DomainStepNotFoundException:
package bdd.steps.tc;import com.blundell.tut.TemperatureConverter;import org.givwenzen.annotations.DomainStep;import org.givwenzen.annotations.DomainSteps;@DomainStepspublic class TemperatureConverterSteps {private static final String CELSIUS = "Celsius";private static final String FAHRENHEIT = "Fahrenheit";private static final String UNIT_NAME = "(" + CELSIUS + "|" + FAHRENHEIT + ")";private static final String ANY_TEMPERATURE = "([-+]?\\d+(?:\\.\\d+)?)";private double inputTemperature = Double.NaN;@DomainStep("I(?: a|')m using the TemperatureConverter")public void createTemperatureConverter() {// do nothing}@DomainStep("I enter " + ANY_TEMPERATURE + " into the " + UNIT_NAME + " field")public void setField(double inputTemperature, String unitName) {this.inputTemperature = inputTemperature;}@DomainStep("I obtain " + ANY_TEMPERATURE + " in the " + UNIT_NAME + " field")public boolean verifyConversion(double expectedTemperature, String unitName) {double outputTemperature = convertInputInto(unitName);return Math.abs(outputTemperature - expectedTemperature) < 0.01D;}private double convertInputInto(String unitName) {double convertedInputTemperature;if (CELSIUS.equals(unitName)) {convertedInputTemperature = getCelsius();} else if (FAHRENHEIT.equals(unitName)) {convertedInputTemperature = getFahrenheit();} else {throw new RuntimeException("Unknown conversion unit" + unitName);}return convertedInputTemperature;}private double getCelsius() {return TemperatureConverter.fahrenheitToCelsius(inputTemperature);}private double getFahrenheit() {return TemperatureConverter.celsiusToFahrenheit(inputTemperature);}}