Archive for December, 2006

SAP Enterprise Portal + Automated Functional Testing – Part 7 of …

5 December, 2006 Comments off

In anticipation of posting about a new topic I’m going to wrap up my Watir Automated testing posts with a few more top tips.

TOP TIP – How do I run a single test?

So you have lots of tests in your test suite but only want to run one? No need to create an ad-hoc test case, simply pass in the –name parameter when running the test:

ruby test_mytestcase.rb --name test_just_this_method

TOP TIP – How do I run the test in background mode?

Running the test so you can see what is going on in the browser is sometimes useful but most of the time you’ll want to run the tests in the background and just see the results. This is easily done by passing the -b parameter on the command line:

ruby test_mytestcase.rb -b

TOP TIP – Helper methods

I have a couple of helper methods which I use in most of my test cases:

def should_find(find_me)
assert(@ie.contains_text(find_me), "*\n*\n*\nText not found: #{find_me}\n*\n*\n*")

def should_not_find(find_me)
assert_nil(@ie.contains_text(find_me), "*\n*\n*\nFound text which should not be present: #{find_me}\n*\n*\n*")

No clever code here it just means I can write tests which are easier to read:

should_not_find("Portal Runtime Error")

Well I’m running out of content about testing as you can probably tell! So I guess that’s a wrap. I’ll no doubt re-visit automated testing again at some point but for now that’s my lot.

I’ve been working on creating web services for Enterprise Portal and calling those web services from Microsoft .Net. I’ve taken lots of notes, so expect a series of EP web services posts real soon.


SAP Portal Developer Guide

5 December, 2006 7 comments

Looking for help on the SAP Portal? HTMLB syntax and lots of other goodies this way…

SAP Portal Developer Guide

SAP Portal how do I reference a Javascript file?

5 December, 2006 Comments off

Easy when you know how

request = (IPortalComponentRequest)this.getRequest();
response = (IPortalComponentResponse)this.getResponse();
IResource jsResource = request.getResource(IResource.SCRIPT, “scripts/myscript.js”);
Categories: SAP Enterprise Portal

Ruby unit testing – run only one test

5 December, 2006 4 comments

If you don’t wish to run all the unit tests in your test case you can tell ruby to run only one by passing in the name of the test:

  ruby test_mytestcase.rb --name test_just_this_method
Categories: Ruby, Testing

Ruby testing – setup project folders

5 December, 2006 Comments off

Its a good idea to keep your test cases seperate from your production code:


When you have your project setup in this way add the following line to the top of your test cases:

Inside test_workomatic.rb

  $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
  require workomatic.rb
Categories: Ruby, Testing

Location of XML files

5 December, 2006 Comments off
Categories: SAP Enterprise Portal

Castle Monorail + Active Record + Testing + CreateSchemaFromFile

5 December, 2006 2 comments

It’s always a good idea to have your test database match your production database exactly to do that use:


Unlike CreateSchema which takes a best guess at how your schema should be CreateSchemaFromFile uses an SQL script which allows you to control exactly what the schema should be.

Call CreateSchemaFromFile as part of your PrepareSchema method in your AbstractTestCase class.

protected virtual void PrepareSchema()
// If you want to delete everything from the model.
// Remember to do it in a descendent dependency order
// Office.DeleteAll();
// User.DeleteAll();
// Another approach is to always recreate the schema
// (please use a separate test database if you want to do that)

Your schema.sql file should contain scripts in the standard MS SQL format:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Application_Status]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Application_Status]

CREATE TABLE [dbo].[Application_Status] (
[ID] [int] NOT NULL ,
[Title] [varchar] (50) NOT NULL ,
[Description] [text] NULL

Categories: MonoRail