Tag Archive for test

tets

test

source

Another Code

 public void testRefreshDoesNothingIfClipBoardContentsNotChanged() {
queue = mockClipBoardQueue(false, "Any thing");

insertDummyValuesIntoQueue(2);
assertFalse(queue.refresh());

assertEquals(2, queue.getQueue().size());
}

source

My Snipplet

Test.java

source

Automated UI test with Selenium-RC, WWW::Selenium and Test::More

use WWW::Selenium;
use Test::More tests => 2;  #update to reflect the number of tests to be run

my $sel = WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*iexplore",  # *iehta has more cross-domain privileges than *iexplore
browser_url => "http://mysite.com",
);
$sel->start();
$sel->open("http://mysite.com/testpopup.html");
diag("Check whether the popup is hidden.");
my $canSeePopup = $sel->is_visible("modalWindow");
ok ($canSeePopup == 0, "Popup is not visible.");
diag("Check whether the magic is hidden.");
ok(
$sel->is_visible("modalWindowMagicLayer") == 0,
"CSS magic is hidden... for now."
);
$sel->stop();;

source

Dada main

public class Dada {
public static void main(String[] args) {
System.out.println("Post your snippets with snipplr4e.");
}
}

source

Does an object have a specific property?

if ("foo" in myObject) {}

source

Does an element exist?

<div id="bar" />
<script>
if (document.getElementById('foo') == null) {
alert('foo is missing!');
}
//or:
if ( ! document.getElementById('bar')) {
alert('bar is missing!');
}
</script>

source

Initialize cart test helper

  # CHANGED: Initialize cart.
def initialize_cart
@cart = @request.session[:cart] ||= Cart.create
end

source

foo

test this for me please

source

assert_difference

module AssertHelper
# Author:: <a href="http://blog.caboo.se/articles/2006/06/13/a-better-assert_difference" >http://blog.caboo.se/articles/2006/06/13/a-better-assert_difference</a>
#
# == Examples
#   assert_difference Group, :count do
#     post :create, :group => { :name => 'monkeys' }
#   end
#
#   assert_difference [ User, Group ], :count do
#     Membership.create(:user_id => 1, :group_id => 5)
#   end
#
#   assert_difference User, :name, nil do
#     post :update, :id => 5, { :name => 'monkeys' }
#   end
def assert_difference(objects, method = nil, difference = 1)
objects = [objects].flatten
initial_values = objects.inject([]) { |sum,obj| sum << obj.send(method) }
yield
if difference.nil?
objects.each_with_index { |obj,i|
assert_not_equal initial_values[i], obj.send(method), "#{obj}##{method}"
}
else
objects.each_with_index { |obj,i|
assert_equal initial_values[i] + difference, obj.send(method), "#{obj}##{method}"
}
end
end

def assert_no_difference_in_size(object, methods = nil, &block)
assert_difference_in_size object, methods, 0, &block
end
end

source