System test Developers notes

From Informatics

Jump to: navigation, search

Contents

Preparing a new release

  1. copy "Field codes - V1.0.doc" from https://sharepoint.cu-genome.org/c2b2/Testing/ to "c:\workbench\Testing" on local computer
  2. edit "Field codes - V1.0.doc" to reflect correct version.
    • Open "Field codes - V1.0.doc" in MS Word
    • show all Field codes if not visible: Ctrl-a then mouse-right-click-"Toggle Field Codes"
    • modify Project name, e.g. name it geWorkbench1.05: SET PROJECT "geWorkbench1.05"
    • save and exit
  3. copy all relevant scripts to local disk from Head on SharePoint
  4. run script to update Project variable (see below)
    • This script will prepare the worddocuments: to contain the correct version number, and update all fields. It will also enter new "empty" entries into the database.
  5. create new directory in SharePoint under "https://sharepoint.cu-genome.org/c2b2/Testing/" e.g. "Version 1.05"
  6. copy updated scripts to that SharePoint folder
  7. Create table with assignments under relevant version geWorkBench as it is done in geWorkbench-1.05-SystemTesting
    • A list of system tests with relevant links can be found here: SystemTests
    • Adobe GoLive allows to copy columns
    • don't forget to change Head into Version%20<VERSION> within the links
  8. notify System testers about what should be done (Should be somehow automated?)


Updating System tests

  1. Open MS Word
  2. Open Visual Basic Editor (Alt-F11)
  3. Copy the code below into the visual basic editor
  4. Ensure that ActiveX Data Objects is referenced: Tools->References->Microsoft ActiveX Data Objects 2.7 Library
  5. Execute Script: Place cursor into first code snippet and press F5
  6. Select folder where you copied System tests from Head on SharePoint
  7. Thats all there is to it.
Sub updateAllDocs()
   ' This procedure asks for a root directory for system test scripts.
   ' it searches for files that comply to the following pattern: *{oldversiont}.doc
   ' where {oldversion} is set below
   ' It then excecutes "updateFile" on each file found
   ' Thats it.
   
   Dim fileArray() As String, ffile As String, count As Integer
   count = 0
   
   Dim version As String
   
   oldversion = "V2.0"
   newversion = "V2.0"
   
   Dim objShell As Object
   Dim objFolder As Object
   Dim strFolderFullPath As String

   Set objShell = CreateObject("Shell.Application")
   Set objFolder = objShell.BrowseForFolder(0, "Please select a folder", 0)

   If (Not objFolder Is Nothing) Then
       '// NB: If SpecFolder= 0 = Desktop then ....
       On Error Resume Next
       If IsError(objFolder.Items.Item.Path) Then strFolderFullPath = CStr(objFolder): GoTo GotIt
       On Error GoTo 0
       '// Is it the Root Dir?...if so change
       If Len(objFolder.Items.Item.Path) > 3 Then
           strFolderFullPath = objFolder.Items.Item.Path & Application.PathSeparator
       Else
           strFolderFullPath = objFolder.Items.Item.Path
       End If
   Else
       MsgBox "User cancelled": GoTo FINAL_EXIT
   End If

GotIt:
   res = MsgBox("You selected " & strFolderFullPath, vbOKCancel, Title:="Path to root of test scripts")
   If res = 2 Then
       GoTo FINAL_EXIT
   End If
   
   With Application.FileSearch
      .fileName = "*" & oldversion & ".doc"
       .LookIn = strFolderFullPath
       .SearchSubFolders = True
       .Execute
       For i = 1 To .FoundFiles.count
           If Strings.InStr(.FoundFiles(i), "~") = 0 Then
               Call updateFile(.FoundFiles(i))
               'GoTo FINAL_EXIT
           End If
       Next i
       count = .FoundFiles.count
   End With
   
FINAL_EXIT:
End Sub



Sub updateFile(fileName As String)
   ' Unprotect document
   ' Update all fields
   ' Update table of content
   ' Protect docuemtn
   ' ??? Print document (commented out)
   ' Upload initial data to DB

   Dim doc As Document
   Dim v As String
   Dim t As Table
   Dim count As Integer
   
   count = 0
   
   'MsgBox fileName
   
   Set doc = Documents.Open(fileName:=fileName, _
       ConfirmConversions:=True, ReadOnly:=False, AddToRecentFiles:=False, _
       Format:=wdOpenFormatAuto)
   
   If doc.ProtectionType <> wdNoProtection Then doc.Unprotect
   doc.SelectAllEditableRanges
   doc.Fields.Update
   doc.TablesOfContents.Item(1).Update
   doc.Protect Type:=wdAllowOnlyFormFields, Password:=""
   
   'doc.PrintOut
   
   ' Update database with empty entry
   Dim project As String ' name of the project
   If ActiveDocument.Bookmarks.Exists("PROJECT") = True Then
       project = ActiveDocument.Bookmarks("PROJECT").Range.Text
   Else
       MsgBox ("Bookmark 'Project' is missing")
       'GoTo ENDE
   End If

   ' Create connection to database
   Set conn = New ADODB.Connection
   conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=afdev2.c2b2.columbia.edu;DATABASE=system_tests;UID=bernd;PWD=yagla007;OPTION=16427"
   conn.CursorLocation = adUseClient
   conn.Open
      
   Set rs = New ADODB.Recordset
   rs.Open "SELECT * FROM log WHERE 1=0", conn, adOpenStatic, adLockOptimistic
   rs.AddNew
       
   ' Upload data to database
   rs!user = "none"
   rs!Date = 0
   rs!status = "none"
   rs!moduleTested = ActiveDocument.Name
   rs!project = project
   rs.Update
   rs.Close
   conn.Close
   
upFileEND:
   doc.Close _
      SaveChanges:=wdSaveChanges
End Sub

Developing System tests

  • Check Online Help
  • Check Mantis Bugs
  • Check use cases

Modifying / writing system tests

System tests for development are stored on the SharePoint server under "Head" as protected documents (a MS Word feature). Storing them as protected documents allows copying the scripts to a new release branch. Therefore, the scripts have to be unprotected before editing (Tools - Unprotect Document). It should not be neccessary to write a new script from scratch; the recommended approach is to copy/modify an existing script.

System tests are located in a directory structure that resembles the logic of geWorkbench. (See share point for examples)

What should be tested

  • mathematical correctness
  • dataset history
  • Error messages: wrong input leads to error message
  • 'All Markers' and 'All arrays' check box functionality
  • overlapping marker/microarray sets
  • an analysis should be at least run twice
  • save-load (if there is a new node created) (use field code: FileClose) + rerun first analysis
  • individual parameters: It is possible that parameters have been exchanged in the development process...
  • each parameter change should give a new result.
  • is on line help available.
  • save/load settings
  • check console (use field code:Closing)
  • too little data error message
  • grid versions should be tested to the same extend as local versions (complete copy)

A few things have to be noted:

  • In order for the database connection to work the field code bookmark "PROJECT" needs to be defined. This is done within the word document "Field codes - V1.0.doc". Thus it is important to insert this document with '{INCLUDETEXT "c:\\workbench\\Testing\\Field codes - V1.0.doc"}'. When editing an existing script this is already included. "Field codes - 1.0.doc" has to be installed on the local C drive under "c:\workbench\Testing" when updating field codes within system tests. The Field codes file uses MS field codes to store text. Another way that is currently being tested is the use of bookmarks. Those are listed in bookmarks.doc in the same directory ("c:\workbench\Testing"). Bookmarks can be referred to by the following construction: {INCLUDETEXT "c:\\workbench\\Testing\\bookmarks.doc" bookmarkName}. Inside "bookmarks.doc" bookmarks can be assigned to text by insert-bookmark. Under Tools-Option-View there is check-box called Bookmarks that controls whether the bookmarks are visually highlighted.
  • The drop-down forms are best copied. The order of the entries within the drop-down forms is important since this also dictates their priority (relative severity of each error).
  • Field codes and drop-down forms cannot be put into other field codes and then loaded from the "Field codes - V1.0" file.
  • The file "Field codes - V1.0" also contains predefined steps for e.g. opening a specific test data set. Those templates can be reused in different scripts and therefore only have to be modified once.
  • The filename of the system test should end in "V2.0.doc". This is needed for consistency and to be able to move all the files to a different version at some later time point.
  • After a system test is written it has to be made public under this link

Some tips

  • You can quickly change between field codes by using Alt-F9.
  • Inserting a new Field code is done with CTRL-F9.
  • For links to work with Explorer 7.0 you should add sharepoint to your trusted sites under tools/Internet options/Security/Trusted sites
  • Bernd Jagla recorded a tutorial on how to prepare for a new release and develop new system tests. The two files can be found here and here.
Personal tools