2 Work with projects
A typical TestWise project is a folder consisting of
- project file (xxx.tpr)
- test script files (_spec.rb or _test.rb)
- page class files (_page.rb under /pages folder)
- test helper (test_helper.rb)
- test data (under /testdata folder)
The project file extension is .tpr, which stores the settings. The .tws in the same folder is workspace file, which stores your work settings (such as remembering last file you opened). It is recommended that not check in .tws file in your version control system.
2.1 Open an existing project
If you are new to TestWise, the best place to start is the demo project (included in TestWise under samples\demo). Select File → Open Project (^↑O|⌘↑O), and choose the c:\Program Files\samples\demo\demo.tpr (project file).
In TestWise, only one project can be opened at one time.
2.2 Create a new project
Using File → New Project will bring up the window shown below.
You need to enter project name and project folder. If the folder already exists, TestWise will scan files with extensions described above (spec.rb, *page.rb, …). If in doubt, start with a new folder. Test files will be named with XXX_spec.rb or XXX_test.rb based on naming convention.
Here is a sample one.
You will see the following files created. Select hello_test.rb and click Run button on the Toolbar , you shall see an IE browser window starts up with your web site.
2.3 Create a new test file
Now you shall have a project created and a sample hello_test.rb running. There are several ways to start adding new test files to the project.
2.3.1 Rename existing file
Right mouse click selected file and select ‘rename’.
2.3.2 Add a new file under a folder
Right mouse click selected folder and select ‘New spec’ or ‘New test file’ (which suffix _spec or _test respectively).
2.3.3 Copy existing file
Select an existing file, press F5 to create a new file with its content.
2.4 Project Settings
You can get to project setting dialog via Menu (‘Tools’→‘Project Settings’) or Ctrl+Alt+,.
The setting in ‘General’ Tab is pretty much self explainary. The second tab ‘Environments’ allows user to configure the host url for different environments (called servers in some organisations), so that users can run tests against different environments with simple switch.
The ‘Test Template’ and ‘Page Template’ Tabs are cutomizing the template test and page files.
2.5 Find and Replace in Projects
Using Search → Find in Project (^↑F|⌘↑F) will bring up standard search and replace window shown below.
Here you can search all (text) files in current project and do replacement selectively. ‘Replace selected’ is not supported when searching by regular expression.
2.6 Navigation in project
2.6.1 Go to File
You can quickly move to a file using Go to File … in the Navigation menu (^T|⌘T), this opens a window like below.
This window list all text files in the project alphabetically.
2.6.2 Go to Test Case
A test file often contains multiple test cases, and test cases may have descriptive (long) names. Go to Test Case in the Navigation menu (^↑T|⌘↑T) help you get to specific test case quickly. You might find yourself using it often.
2.6.3 Go to Function
A Function is a piece of scripts maybe reusable or make test scripts more readable.
For example, you might have the following script in
open_browser("http://www.TestWise.com/support") enter_text("user_name", "john") enter_password("password, "password") click_button("Login") click_link("feedback")
Now define login_as function in test_helper (if you follow TestWise convention, functions in test_helper.rb are available to all test files)
def login_as(username, password="password) enter_text("user_name", "john") enter_password("password, "password") click_button("Login") end
Then you can refactor (meaning: change for better without affecting functionality) origin test.
open_browser("http://www.TestWise.com/support") login_as("john", "password") click_link("feedback")
Now the test script is easier to read. Even better, if login function later changed in the application, you just need to update that function!
Go to Function in the Navigation menu (^↑D|⌘↑D) will take you quickly to the functions defined in the helper or page class files.
2.6.4 Go to Recent Files
Recent files… in the Navigation menu (^E|⌘E) will show files you recently visited sorted by last use.