Restore MSSQL Database

Posted on by 0 comment

Kill active sessions

Firstly, it would be better to stop all the applications/services which are connecting to the Database which needs a restore.
Then, kill the active sessions as this will block the restore process if there are any active sessions.

Restore DB

Change user

Category: MSSQL

Simple Dependency Injection with dynamic finder at runtime

Posted on by 0 comment

Sometimes, we have multiple methods to be called, but it has to be determined at run time, so try to make it less coupled and use reflection to achieve this. The sample scenario here is for Field Type. We have different implementation for each different field type, such as text, date etc., and at run time, a DoSomething method should be called based on the field type.

Firstly, an interface is defined, which has methods called IsValid and DoSomething, IsValid method is used for a certain implementation which is valid for certain Fieldtype.

Then, implement the finder method which accepts a TestFieldType parameter. And now we are able to GetTestField based on the parameter we pass, and call the respective DoSomething method as desired.

Category: C#

TOSCA Distributed Execution

Posted on by 0 comment

This exercise will try out TOSCA Distributed Execution, the benefits of using it are

  1. Supports untended execution, creates RDP connection automatically while execution
  2. Splits the execution load to multiple agent system
  3. Monitors the actual test execution with Test Event Monitor

After installing the TOSCA 9.3, the Distributed execution components are under C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\DistributedExecution

Distribution Server

For installing the distribution server, InstallServer.bat under DistributedExecution\Server should be executed,
parameter IP address & Port can be assigned if required.
The ToscaDistributionServer.exe will be configured as windows service, and RDP service will be started after the installation. In case of restarting the server, RDP should be started manually with command

Distribution Agent

Open DistributedExecution\Agent\ToscaDistributionAgent.exe.config, and update few parameters below.

  • CommunicationService endpoint points to the distribution server
  • UserSettings\Tricentis.DistributionAgent.Properties.Settings\Workspace
  • UserSettings\Tricentis.DistributionAgent.Properties.Settings\UserName
  • UserSettings\Tricentis.DistributionAgent.Properties.Settings\Password
  • UserSettings\Tricentis.DistributionAgent.Properties.Settings\PortForServerCallbacks

and then start ToscaDistributionAgent.exe with administrator privilege. In the task tray, right click the ToscaDistributionAgent, and select configure agent, it will show a popup windows, in which you configure different configuration parameters; and also enable allow RDP with the username and password for the RDP, then click save to complete the setup.

Execution Monitor

Copy all files under DistributedExecution\Monitor to a server with IIS installed, run Install TestEventMonitor.bat, it will create a virtual directory with name of TestEventMonitor.

Setup in TOSCA

Settings

Go to Settings\Commander\DistributedExecution, and set value to

  • EventMonitor\Url: http://localhost/TestEventMonitor
  • Server\EndpointAddress: http://localhost:9000/ManagerService

Now, we can open Execution Monitor from TOSCA, and see the status of all registered agents.

Test Configuration

Go to Execution\Configurations,
Firstly, right click Configurations, and run task Update configurations from server, it will sync test configurations from server to TOSCA.
Then, add new configuration based the requirement of the tests, such as Memory, Operating system etc.

Test Event

Test Event is required to be created for distributed execution, in which one or multiple test configurations could be assigned, for each test configuration, one or more execution lists could be attached to it. Once the test event is configured, we can kick off the execution with following ways,

  • In TOSCA Commander, right click the event and click Execute Now
  • Trigger the execution through Tosca CI Client

Test Execution Monitor

In TestEventMonitor web page, current execution status will be displayed, including state, event name, Actual result, start time, Create, more details can be seen after clicking the test event item.
The test event can be cancelled in the test event monitor.

Integration with Team City using TOSCA CI Client

Build Steps

Generate TOSCA CI configuration file

  • Runner Type: Powershell
  • Script: Source
  • Script source:

Tests Execution

  • Runner Type: Command Line
  • Run: Executable with parameters
  • Command executable: C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\ToscaCI\Client\ToscaCIClient.exe  
  • Command parameters:-m distributed -c “c:\Temp\CIExeConfig.xml” -t junit -r “c:\temp\result.xml” -x True

Display test result in Team City

In Build features, add a new build feature with following details:

  • Report Type: Ant JUnit
  • Monitoring rules: c:\temp\result.xml
Category: Team City, TOSCA

TOSCA Continues Integration with Team City

Posted on by 0 comment

After installing TOSCA 9.3, TOSCA CI related program should be under C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\ToscaCI.

Preparation in TOSCA work space

  • Create a execution list folder and set attribute ContinuousIntegrationBuildRootFolder to True
  • Create execution list with attribute ContinuousIntegration=True and a desired value for Executiontype
  • Add test cases which you plan to execute to this execution list.

TOSCA CI Client

TOSCA CI professional license is required for using CI configuration file.
Since we will trigger the execution from TeamCity, the TOSCA CI client could be triggered under system account, under that the UI automation will be blocked. So the TOSCA CI Remote Execution Service will be used to execute the test cases.
In this case, we will only need to configure the remote execution service endpoint. It could be on local or remote machine, but it should be started under normal admin account.

TOSCA CI Remote Execution Service

Attributes below in ToscaCIRemoteExecutionService.exe.config should be configured based on your configuration.

  • WorkspacePath
  • LoginName
  • LoginPassword

Unattended Execution

  • The screen saver should be disabled
  • The system should not be locked at any time, a action RDP session should be kept
  • Or Auto logon is enabled, and use VNC or teamviewer to remote connect to the system
  • the system is logged in with the same user which starts the ToscaCIRemoteExecutionService

Team City Integration

Build Steps

Generate TOSCA CI configuration file

  • Runner Type: Powershell
  • Script: Source
  • Script source:

Tests Execution

  • Runner Type: Command Line
  • Run: Executable with parameters
  • Command executable: C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\ToscaCI\Client\ToscaCIClient.exe  
  • Command parameters:-m distributed -c “c:\Temp\CIExeConfig.xml” -t junit -r “c:\temp\result.xml” -x True

Display test result in Team City

In Build features, add a new build feature with following details:

  • Report Type: Ant JUnit
  • Monitoring rules: c:\temp\result.xml
Category: Team City, TOSCA

FindElements By JQuery locator

Posted on by 0 comment

Lots of websites use JQuery, and JQuery selector has more features than Css locator, such as contains etc. So try to use Javascript Executor to execute JQuery selector and return the WebElements.

Category: C#, Selenium