1. M Haidar Hanif
  2. kargu

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.

  • Participants
  • Parent commits 956a3ed
  • Branches develop

Comments (0)

Files changed (12)

File .gitignore

View file
 tmp/
 *.swp
 *.jar
+screenshot_*.png
 
 # Backup files
 *.un~

File build.properties

View file
+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

File features/app_title_id.feature

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

File features/step_definitions/calabash_steps.rb

View file
+require 'calabash-android/calabash_steps'

File features/support/app_installation_hooks.rb

View file
+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

File features/support/app_life_cycle_hooks.rb

View file
+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

File features/support/env.rb

View file
+require 'calabash-android/cucumber'

File features/support/hooks.rb

Empty file added.

File res/layout/activity_main.xml

View file
             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>
 

File run_calabash.sh

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

File sh/run_calabash.sh

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

File tests/manuscript.mkd

View file
+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