Commits

M Haidar Hanif committed c4cd3fb

Begin to use Test-Driven Development (TDD) process

Use Calabash-Android with Cucumber syntax to test.
Add beginning manuscript and scenario features.
Provide configured build properties.
Pack fixed command into shell script.
Ignore generated test screenshot.

Comments (0)

Files changed (12)

 tmp/
 *.swp
 *.jar
+screenshot_*.png
 
 # Backup files
 *.un~
+tested.package_name=com.mhaidarhanif.android.kargu
+tested.main_activity=com.mhaidarhanif.android.kargu
+tested.project.apk=target/kargu.apk
+ 
+android.api.level=10
+ 
+key.store=${user.home}/.android/debug.keystore
+key.store.password=android
+key.alias=androiddebugkey
+key.alias.password=android

features/app_title_id.feature

+Feature: Title feature
+
+  Scenario: As a valid user I can see my app
+    Then I see "Kargu Listrik"

features/step_definitions/calabash_steps.rb

+require 'calabash-android/calabash_steps'

features/support/app_installation_hooks.rb

+require 'calabash-android/management/app_installation'
+
+AfterConfiguration do |config|
+	FeatureNameMemory.feature_name = nil
+end
+
+Before do |scenario|
+  @scenario_is_outline = (scenario.class == Cucumber::Ast::OutlineTable::ExampleRow)
+  if @scenario_is_outline 
+    scenario = scenario.scenario_outline 
+  end 
+
+  feature_name = scenario.feature.title
+  if FeatureNameMemory.feature_name != feature_name \
+      or ENV["RESET_BETWEEN_SCENARIOS"] == "1"
+    if ENV["RESET_BETWEEN_SCENARIOS"] == "1"
+      log "New scenario - reinstalling apps"
+    else
+      log "First scenario in feature - reinstalling apps"
+    end
+    
+    uninstall_apps
+    install_app(ENV["TEST_APP_PATH"])
+    install_app(ENV["APP_PATH"])
+    FeatureNameMemory.feature_name = feature_name
+	FeatureNameMemory.invocation = 1
+  else
+    FeatureNameMemory.invocation += 1
+  end
+end
+
+FeatureNameMemory = Class.new
+class << FeatureNameMemory
+  @feature_name = nil
+  attr_accessor :feature_name, :invocation
+end

features/support/app_life_cycle_hooks.rb

+require 'calabash-android/management/adb'
+require 'calabash-android/operations'
+
+Before do |scenario|
+  start_test_server_in_background
+end
+
+After do |scenario|
+  if scenario.failed?
+    screenshot_embed
+  end
+  shutdown_test_server
+end

features/support/env.rb

+require 'calabash-android/cucumber'

features/support/hooks.rb

Empty file added.

res/layout/activity_main.xml

             android:layout_weight="1"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:focusable="true"/>
+            android:focusable="true"
+            android:singleLine="true"
+            android:inputType="numberDecimal"/>
 
     </LinearLayout>
 
+# Run calabash-android with packaged APK build by Maven
+calabash-android run target/kargu.apk

sh/run_calabash.sh

-# Run calabash-android with packaged APK build by Maven
-calabash-android run target/kargu.apk

tests/manuscript.mkd

+0. Selamat datang di aplikasi Kargu! Sekarang adalah pertama kali Anda menggunakan Kargu. Silakan ikuti petunjuk penggunaan berikut.
+   *  Tombol: Lanjut
+1. Untuk memulai perhitungan, Anda perlu mengetahui:
+   -  Batas daya listrik bangunan seperti rumah atau kamar
+   -  Alat elektronik apa saja yang digunakan
+   -  Waktu penggunaan rata-rata sehari dalam jam
+   *  Tombol: Lanjut
+2. Masukkan nilai daya listrik (dalam VA atau Volt Ampere)
+   *  Tombol: Lanjut
+3. Pilih alat elektronik yang tersedia atau tambahkan sendiri
+   -  Jika memilih yang sudah ada, beri nilai waktu
+   -  Jika menambah sendiri, beri nilai Watt dan waktu
+   *  Tombol: Lanjut
+4. Tekan tombol hitung dan silakan lihat hasil laporannya
+   *  Tombol: Coba