Skip to content

Commit

Permalink
Added: First approach of a Test Explorer program, called "TestExecuto…
Browse files Browse the repository at this point in the history
…r", as GUI.
  • Loading branch information
sven.seyfert committed Oct 22, 2021
1 parent 35c40c7 commit 9ed2b59
Show file tree
Hide file tree
Showing 20 changed files with 915 additions and 11 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to "Au3TestFramework" will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.14.0] - 2021-10-22

### Added

- First approach of a Test Explorer program, called "TestExecutor", as GUI.
- Visualization of all features, scenarios, the execution state and execution duration (still WIP).
- Library "GUIScroll.au3" (utilities).

### Changed

- Minor function adjustments for the StepGenerator.

## [0.13.0] - 2021-10-19

### Added
Expand Down Expand Up @@ -64,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- All repository data and dependencies (already added before in version v0.8.0).

[0.14.0]: https://github.com/Sven-Seyfert/Au3TestFramework/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/Sven-Seyfert/Au3TestFramework/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/Sven-Seyfert/Au3TestFramework/compare/v0.11.0...v0.12.0
[0.11.0]: https://github.com/Sven-Seyfert/Au3TestFramework/compare/v0.10.0...v0.11.0
Expand Down
Binary file modified build/FeatureGenerator.exe
Binary file not shown.
Binary file modified build/FormatBddTable.exe
Binary file not shown.
Binary file modified build/StepsGenerator.exe
Binary file not shown.
Binary file added build/TestExecutor.exe
Binary file not shown.
55 changes: 55 additions & 0 deletions src/Execution/TestExecutor/BasicFunctionController.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Func _stringProperWithSpaces($sString)
Local $sCharacter = ''
Local $sProperString = ''
Local $iCharactersCount = StringLen($sString)

For $i = 1 To $iCharactersCount Step 1
$sCharacter = StringMid($sString, $i, 1)

If StringIsUpper($sCharacter) Then
$sProperString &= ' ' & $sCharacter
Else
$sProperString &= $sCharacter
EndIf
Next

Return StringTrimLeft($sProperString, 1)
EndFunc

Func _getJustFileName($sFilePath)
Return StringRegExpReplace($sFilePath, '(.+?)\\', '', 0)
EndFunc

Func _getCount($aList)
Return UBound($aList) - 1
EndFunc

Func _getFileContentAsList($sFileContent)
Return StringSplit(_getFileContent($sFileContent), @LF, 1)
EndFunc

Func _getFileContent($sFile)
Local Const $iUtf8WithoutBomMode = 256

Local $hFile = FileOpen($sFile, $iUtf8WithoutBomMode)
Local $sFileContent = FileRead($hFile)
FileClose($hFile)

Return $sFileContent
EndFunc

Func _writeFile($sFile, $sText)
Local Const $iUtf8WithoutBomAndOverwriteCreationMode = 256 + 2 + 8

Local $hFile = FileOpen($sFile, $iUtf8WithoutBomAndOverwriteCreationMode)
FileWrite($hFile, $sText)
FileClose($hFile)
EndFunc

Func _appendToFile($sFile, $sText)
Local Const $iUtf8WithoutBomAndAppendMode = 256 + 1

Local $hFile = FileOpen($sFile, $iUtf8WithoutBomAndAppendMode)
FileWrite($hFile, $sText)
FileClose($hFile)
EndFunc
74 changes: 74 additions & 0 deletions src/Execution/TestExecutor/DeclarationBuilder.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Global $sCheckboxLevelFeatureName = 'Feature'
Global $sCheckboxLevelScenarioName = 'Scenario'
Global $sIncludeFileOfScenarioSteps = 'IncludeFileOfScenarioSteps.au3'

Global $iCount = 0
Global $iSuccessCounter = 0
Global $iFailureCounter = 0
Global $iNoExecutionCounter = 0

Global $aTableOfCheckboxesData[0][5]

Global $aGui[$iMaxEnumIndex]
$aGui[$eHandle] = Null
$aGui[$eTitle] = 'TestExecutor'
$aGui[$eXPosition] = Default
$aGui[$eYPosition] = Default
$aGui[$eWidth] = 800
$aGui[$eHeight] = 600
$aGui[$eStyle] = BitOR($GUI_SS_DEFAULT_GUI, $WS_HSCROLL, $WS_VSCROLL)
$aGui[$eFont] = 'Consolas'

Global $aCustomButtonRun[$iMaxEnumIndex]
$aCustomButtonRun[$eHandle] = Null
$aCustomButtonRun[$eTitle] = ''
$aCustomButtonRun[$eXPosition] = 15
$aCustomButtonRun[$eYPosition] = 9
$aCustomButtonRun[$eWidth] = Default
$aCustomButtonRun[$eHeight] = Default

Global $aCustomButtonSelectAll[$iMaxEnumIndex]
$aCustomButtonSelectAll[$eHandle] = Null
$aCustomButtonSelectAll[$eTitle] = ''
$aCustomButtonSelectAll[$eXPosition] = 43
$aCustomButtonSelectAll[$eYPosition] = 12
$aCustomButtonSelectAll[$eWidth] = Default
$aCustomButtonSelectAll[$eHeight] = Default

Global $aCustomButtonUnselectAll[$iMaxEnumIndex]
$aCustomButtonUnselectAll[$eHandle] = Null
$aCustomButtonUnselectAll[$eTitle] = ''
$aCustomButtonUnselectAll[$eXPosition] = 62
$aCustomButtonUnselectAll[$eYPosition] = 1
$aCustomButtonUnselectAll[$eWidth] = 28
$aCustomButtonUnselectAll[$eHeight] = 28

Global $aCheckboxFeature[$iMaxEnumIndex]
$aCheckboxFeature[$eHandle] = Null
$aCheckboxFeature[$eTitle] = Null
$aCheckboxFeature[$eXPosition] = 32
$aCheckboxFeature[$eYPosition] = Null
$aCheckboxFeature[$eWidth] = $aGui[$eWidth] - 150
$aCheckboxFeature[$eHeight] = Default

Global $aCheckboxScenario[$iMaxEnumIndex]
$aCheckboxScenario[$eHandle] = Null
$aCheckboxScenario[$eTitle] = Null
$aCheckboxScenario[$eXPosition] = 49
$aCheckboxScenario[$eYPosition] = Null
$aCheckboxScenario[$eWidth] = $aGui[$eWidth] - 150
$aCheckboxScenario[$eHeight] = Default

Global $aColor[$iMaxEnumIndex]
$aColor[$eGreen] = 0x8BB965
$aColor[$eRed] = 0xF03A17
$aColor[$eBlue] = 0x1BA1E2
$aColor[$eGray] = 0xCDCDCD

Global $aIcon[$iMaxEnumIndex]
$aIcon[$eSum] = ''
$aIcon[$eSuccess] = ''
$aIcon[$eFail] = ''
$aIcon[$eNotExecuted] = ''
$aIcon[$eFolder] = '📂'
$aIcon[$eClock] = ''
24 changes: 24 additions & 0 deletions src/Execution/TestExecutor/Enum.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Global Enum _
$eBlue, _
$eClock, _
$eFail, _
$eFolder, _
$eFont, _
$eGray, _
$eGreen, _
$eHandle, _
$eHeight, _
$eMessageNoScenarioChosen, _
$eMessageNoStepFiles, _
$eMessageTitleNoStepFiles, _
$eMessageTitleNothingChosen, _
$eNotExecuted, _
$eRed, _
$eStyle, _
$eSuccess, _
$eSum, _
$eTitle, _
$eWidth, _
$eXPosition, _
$eYPosition, _
$iMaxEnumIndex
34 changes: 34 additions & 0 deletions src/Execution/TestExecutor/ExecutionController.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Func _executeScenarios()
$aTableOfCheckboxesData = _setCheckboxesState($aTableOfCheckboxesData)

Local $aTableOfSelectedScenarios = _getSelectedScenarios($aTableOfCheckboxesData)

If UBound($aTableOfSelectedScenarios) == 0 Then
MsgBox(48, $aTexts[$eMessageTitleNothingChosen], $aTexts[$eMessageNoScenarioChosen])

Return
EndIf

_ArrayDisplay($aTableOfSelectedScenarios, 2)

_includeStepFiles()

;~ TODO
EndFunc

Func _includeStepFiles()
Local $aStepFileList = _getListOfFiles('Steps', '*Steps.au3')

If Not IsArray($aStepFileList) Then
MsgBox(48, $aTexts[$eMessageTitleNoStepFiles], $aTexts[$eMessageNoStepFiles] & @CRLF & @CRLF & _
'Folder:' & @CRLF & '*\Specification\Steps\')

Return
EndIf

_writeFile($sIncludeFileOfScenarioSteps, '')

For $i = 1 To _getCount($aStepFileList) Step 1
_appendToFile($sIncludeFileOfScenarioSteps, '#include "' & $aStepFileList[$i] & '"' & @CRLF )
Next
EndFunc
64 changes: 64 additions & 0 deletions src/Execution/TestExecutor/FunctionController.au3
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Func _showTestExecutor()
Local $aListOfFeatureFiles = _getListOfFiles('Features', '.feature')
Local $aTableOfFeatureFilesAndTheirScenarios = _getTableOfFeatureFilesAndTheirScenarios($aListOfFeatureFiles)

_writeFile($sIncludeFileOfScenarioSteps, '; temporary dummy text')

_createGui()
_createDynamicGuiContent($aTableOfFeatureFilesAndTheirScenarios)
_createButtonBar()
_initializeGuiScroll()
_waitForGuiEvent()
EndFunc

Func _getListOfFiles($sFolder, $sFileExtension)
If @Compiled Then
Local $sFilePath = _PathFull('..\src\Specification\' & $sFolder & '\')
EndIf

If Not @Compiled Then
Local $sFilePath = _PathFull('..\..\Specification\' & $sFolder & '\')
EndIf

Local Const $iOnlyFiles = 1
Local Const $iRecursive = 1
Local Const $iSortAsc = 1
Local Const $bAbsolutePath = 2

Return _FileListToArrayRec($sFilePath, '*' & $sFileExtension, $iOnlyFiles, $iRecursive, $iSortAsc, $bAbsolutePath)
EndFunc

Func _getTableOfFeatureFilesAndTheirScenarios($aList)
Local $aTableOfFeatureFilesAndTheirScenarios[1][4]

For $i = 1 To _getCount($aList) Step 1
Local $aFileContent = _getFileContentAsList($aList[$i])

$aTableOfFeatureFilesAndTheirScenarios = _createTableOfFeatureFilesAndTheirScenarios($aTableOfFeatureFilesAndTheirScenarios, $aFileContent, $aList[$i])
Next

Return $aTableOfFeatureFilesAndTheirScenarios
EndFunc

Func _createTableOfFeatureFilesAndTheirScenarios($aTable, $aFileContent, $sFeatureFilePath)
Local $sRegExPatternOfFeatureSubFolderPath = '(.+?)Features'
Local $sRegExPatternOfScenarioTitle = 'Scenario:.+?$'

For $j = 1 To _getCount($aFileContent) Step 1
If StringInStr($aFileContent[$j], 'Scenario:', 2) == 0 Then
ContinueLoop
EndIf

Local $sFeature = _getJustFileName($sFeatureFilePath)
Local $sFeatureFolderPath = StringTrimRight($sFeatureFilePath, StringLen($sFeature))
Local $sFeatureSubFolderPath = StringRegExpReplace($sFeatureFolderPath, $sRegExPatternOfFeatureSubFolderPath, '')
Local $sFeatureFolderBreadcrumb = 'Features' & StringTrimRight(StringReplace($sFeatureSubFolderPath, '\', ' > '), 2)
Local $sFeatureName = _stringProperWithSpaces(StringReplace($sFeature, '.feature', ''))
Local $sScenario = StringRegExp($aFileContent[$j], $sRegExPatternOfScenarioTitle, 1)[0]
Local $sScenarioName = StringReplace($sScenario, 'Scenario: ', '')

_ArrayAdd($aTable, $sFeatureFolderBreadcrumb & '|' & $sFeatureName & '|' & $sScenarioName & '|' & $sFeatureFilePath)
Next

Return $aTable
EndFunc
Loading

0 comments on commit 9ed2b59

Please sign in to comment.