Skip to content

Instantly share code, notes, and snippets.

View leviwilson's full-sized avatar

Levi Wilson leviwilson

  • Northwoods
  • Colorado, USA
View GitHub Profile
@leviwilson
leviwilson / HttpUrlActivityTest.java
Created September 4, 2012 16:24
Mock HttpURLConnection Example
package com.example.robolectric;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
import static org.mockito.Mockito.verify;
import java.io.IOException;
import java.net.*;
import org.junit.Before;
import org.junit.Test;

Poor Man's VPN

Create an AWS EC2 Linux Instance

  1. Sign into your AWS account console
  2. Choose an availability zone not in your area (like Oregon or something)
  3. Launch a new instance (just choose an Ubuntu instance). A t2.micro should be fine for this.
  4. You may have to create a new key pair if you haven't already. Name it and the download the file. Do not lose this as this <whatever>.pem file is what you'll use to access the instance.

SSH Tunnel Into It

Now that you have an EC2 instance running in some other area of the country, you will want to SSH tunnel into

@leviwilson
leviwilson / codmash_abstract_2013.md
Last active March 30, 2018 21:03
Abstract for Codemash 2014: Automating Windows Applications with Ruby.

Codemash 2014 Pre-Compiler

Automating Windows Applications with Ruby

Abstract

When we think of writing automated tests with ruby and cucumber, Windows desktop applications are not the first thing that come to mind. If you have looked into writing acceptance tests for Windows applications (native, WinForms or WPF), chances are you have come across solutions such as SpecFlow or Raconteur, but what are the options if we want to drive our tests from ruby using cucumber or RSpec?

This pre-compiler session will take you through building an acceptance test suite using some ruby gems (mohawk, RAutomation and cucumber) that tap into the Microsoft UI Automation accessibility framework to automate native, WinForms and WPF applications.

Target Audience

@leviwilson
leviwilson / GsonDateFormatTest.java
Created April 26, 2012 03:47
Gson Date / Milliseconds
package com.leviwilson.test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import java.util.Date;
import org.junit.Test;
*.csproj -text merge=union
*.sln -text merge=union
@leviwilson
leviwilson / memory_backed_disk.md
Created December 5, 2013 01:58
Create memory backed disk on OSX

Create a memory-backed disk in OSX. Useful for sending git filter-branch to it to speed things up.

# to mount
hdiutil attach -nomount ram://$(( 128 * 1024 * 2 )) # returns device with 128 MB (in 512k blocks)
diskutil erasevolume JHFS+ "tmp" /dev/disk1 # whatever the hdiutil command returns

# when done
diskutil unmount /dev/disk1
hdiutil detach /dev/disk1
@leviwilson
leviwilson / UIA.rb
Last active December 25, 2015 07:19
main_form = UIA.find_by_id('MainFormWindow')
main_form.children # => [...] array of 22 child elements
main_form.children.find {|e| e.name == 'DropDown List'}.children.map(&:name) # => ['Apple', 'Orange', 'Banana']
main_form.children.first.click
@leviwilson
leviwilson / multiple_screen_calls.rb
Created September 20, 2013 15:53
Calling same method for multiple screens
def show_deleted_for(cls)
on(cls).show_deleted = true
end
def hide_deleted_for(cls)
on(cls)show_deleted = false
end
[CaseActivityTab, MemberNotesTab].each do |cls|
show_deleted_for(cls)
@leviwilson
leviwilson / README.md
Last active December 22, 2015 22:39
Setting up Ruby / DevKit on Windows

Ruby on Windows Setup

Here are a few things you'll need to get ruby setup on your Windows machine.

Ruby Setup

Ruby 1.9.3 will work. Use the defaults, but choose to add all of the ruby executables to your path.

DevKit

DevKit is needed for ruby to be able to install native gems (compiled C++ code) to your system. Extract this into something like c:\DevKit and then run the following commands.

@leviwilson
leviwilson / README.md
Last active December 21, 2015 08:59
Issue loading GitHub Android's HomeActivity

Update

The brazenhead project had the android.support.v4.jar within its libs folder, even though it was not using it. This conflicted with the android.suppor.v4 that the app it was instrumenting was using. Removing this file fixed my issue.

Problem

The way brazenhead is able to instrument any apk for testing models this Robotium Wiki Page. Basically, you need these things to blackbox text any apk:

  • Test apk is signed with the same keystore as the apk you are testing
  • The targetPackage property is the same as the package of the apk that you are testing

That's pretty much it. Then, to launch any activity, you basically do what that article describes: