How to create and use test scripts

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

Contents

Test script

Why

To test the functions of MapWindow it is possible to create a test script.
These test scripts are also used to confirm a reported issue.
Also test scripts are being generated to test all properties and methods of certain classes.
Like the Shapefile, Shape, Image and Grid classes.

How

Use SVN and download the folder: http://svn.mapwindow.org/svnroot/TestingScripts/
Use TestingScriptTemplate.cs.txt as your base test script.

The naming convention of the test scripts is: Classname_Propertyname or Classname_Methodname or Classname_Method_Property for testing classes.
For example: Shapefile_CacheExtents or MapWinGeoProc_DataManagement_CopyShapefile
Naming a script to confirm a bug is: Bug-bugnumber-shortdescription, like Bug-1211-StopEditingTable
The name of a script to test a function is TestShortdescription, like TestImageFormats

In the mwGeoProc a new class called TestMethods is available.
It holds a set of methods that are very handy and easy to use in the test scripts.
If you create your test script using the template you'll have direct access to this class.

Scripts can be written in C# and VB.NET, but C# is preferred.
C# scripts need to be StyleCop compliant.

If you have a Pro version of Visual Studio you can get a ReSharper license code from us to use when developing for MapWindow.
Mail me for more info: Paul Meems

Running scripts

You can run the scripts manually by opening the script in MapWindows script editor.
Start MapWindow, go to Plug-ins --> Scripts

Testing tool

You can also run the script in a more automated manner.
Copy System.Data.SQLite.dll and TestingTool.exe from http://svn.mapwindow.org/svnroot/TestingScripts/TestingTool/bin/Debug/ to the folder with MapWindow.exe.

Start the testing tool, change the location at the top to the correct locations.
Hit the 'Refresh scripts' button and the scripts are loaded.
Scripts that start with '_' in the name are skipped.

Now you can check the scripts you want to run and hit the 'Run' button.
For every script an new instance of MapWindow is loaded and closed when the script has finished.

At the end a webpage will be shown with the test results.
Failed means the script was not successful, the reason can be the test failed or the script was not yet completed. Generated scripts fail by default because no test has been implemented.
OldScript means the script was not yet converted to the new test template or the script threw a compile error. Either way the script needs to be modified.
Successful means the test passed.

The testing tool is still in Beta and will be modified in the next months. So make sure you grab the latest version now and then.
The tool is creating a new folder called _TestResults. In this folder will the test results files (xml) be saved and the SQLite database and the testresults.xsl.
The tool will check for the last two files and create them if they don't exist. So it is wise to delete testresults.xsl when you grabbed a new version of the tool to get the latest one. The database will no longer be changed.


How to create a test script

In the TestingScripts folder is a Solution file called TestingScripts.sln.
Open it and you'll get several projects:

  1. DebuggingPlugin
  2. Scripts
  3. ScriptsVB
  4. TestingTool

The last project is to modify the TestingTool.
You can add your script to the two scripts project. Then you'll get code completion and can even build the project to check for compile errors.
Next you can copy and paste the code in MapWindows Script editor and run the script.


How to debug a test script

Using the DebuggingPlugin project you can debug your script.
Include your script in this project.
Open DebuggingPlugin.cs and change the call to ScriptMain in the method ItemClicked()
Set this project as startup project and run it. MapWindow will start and the plug-in will be loaded.
A new menu is added, select "Run test script" and your script will be executed and the debugger will stop at your breaking points.


Paulmeems 12:12, 29 September 2010 (UTC)

Retrieved from "http://mapwindow.org/wiki/index.php/How_to_create_and_use_test_scripts"

This page has been accessed 73 times. This page was last modified on 29 September 2010, at 12:12.