Powershell Script for Testing Script Generation
To test local and dev script generation.
Join the DZone community and get the full member experience.Join For Free
I have used Powershell for testing. I will explain a scenario in the story format:
Sequence 1: We have a script generation web app, there is a change in the script generation process.
Sequence 2: There were around 2000 scripts that are already in production and these crucial and legacy codebase.
Sequence 3: The code changes are done, but I was not sure how to test them. That's when I started writing the PowerShell script to generate the scripts from local and prod applications and compare them.
Sequence 4: First get HTTP request as below screenshot. Open Chrome Developer Toos, right-click on the GET/POST request, and you will be able to see as per the below screenshot.
Sequence 5: You can use Powershell ISE to write the script. You can create in Start Menu as below screenshot.
Sequence 6: Create a function, so that we can generalize for generic purposes.
$directory— where the file names are present
$localURL— local workspace URL where code changes are made
$devURL— Production URL to generate script
$tempLocalGen— Store Script in this directory
$tempLocalGenSorted— Store Script in this directory sorted because the script generated can be jumbled, compare I have sorted it.
$tempDevGen— Store Script in this directory
$tempDevGenSorted— Store Script in this directory sorted because the script generated can jumble, to compare I have sorted it.
Sequence 7: To read all SQL files in the directory.
Sequence 8: This is what the request looks like.
Sequence 9: To sort the file content, it will be easy to compare as the script generation might jumble.
Sequence 10: To compare the file content I have used the below conditions.
Opinions expressed by DZone contributors are their own.