Testing |
The following topics descriptive the SOWI Testing concept.
This topic contains the following sections:
What | Description |
---|---|
SOWI Test Unit | All tests based on SIC.Test.HelperTestUnit |
Preparation Session | If necessary, set the following values SOWI App Management Module by means of method ModuleSetModule SOWI App Managment User Role by means of method UserRoleSetUserRole Creates and starts HTTP Context object by means of method WebHostCreate Note: User and Client exists. See example below. |
Preparation Test Case | Example of test object of SOWI Test Web/Win Controller and SOWI Test App and SOWI Test Data see Test Objects |
Run Test Case | Method WebHostCreate supported SOWI Test Web Controller |
Example of preparation of Session
/// <summary> /// Test session setting /// Note: object Directory and Log is available. /// </summary> protected override void OnSessionSetting() { //* register module and puts standard permissions * SOWIApp.Management.Module.SetModule("SOWIAppStandardFileContent", "Test",true, true,true,true,true,true,true, 0); //* creates a HTTP context object * SIC.Test.Helper.WebHost.Create(); //* web session log in * SOWIWeb.Helper.Session.LogIn(Properties.Settings.Default.UserName, Properties.Settings.Default.UserPassword); //* puts User Role * SOWIApp.Management.UserRole.SetUserRole(SOWIWeb.Helper.Session.ClientID, SOWIWeb.Helper.Session.UserName); }
Uses assembly SIC.Test.Helper for programming test units. This assembly has some helpful function e.g. supported web host for web testing.
What | Description |
---|---|
Test Unit | Test unit over e.g. a class including all test cases. Based on SIC.Test.Helper.TestUnit |
Test Case | Test case parts:
|
Construct | Initialize and settings of objects: |
Condition | Condition check by method IsTrue. The result is true or false. |
Result | Summary of result about conditions. |
Clean Up | Test case clean up |
What | Syntax | Example |
---|---|---|
Test project name | [Project name].Test | SOWIWeb.Quali.Test |
Test unit/class name | [Project name]Test[Class name] | SOWIWebQualiTestQualiTemplate |
Test case/method name | Test[Project name][Class name][Method name][Parameter] | TestSOWIWebQualiQualiTemplateIndex |
A example of test project folders shown in Solution Explorer
Sorted by A-Z
Name | Content |
---|---|
App_Data | SOWI configuration file (SOWIApp.sconfig) for test database |
ClassDiagram | Sometimes can help to display classes so stored in this folder |
Controllers | Is it a Web test project then has this folder all web test controllers (MVC pattern) |
Data | This folder contains all test files. It's a default value from SIC.Test.HelperDirectory |
TestObject | Test classes for test cases. It can subfolder contained. |
Views | Is it a Web test project then has this folder all web views from his controller (MVC pattern) |
Work | This folder contains all test results (when ResultRedirection empty and ResultRedirect equal false). It's a default value from SIC.Test.HelperDirectory |
MS Visual Studio dialog "Create Unit Tests" can't support SOWI testing because SOWI name notation has a dot character e.g. project name SIC.Draw.
Note: for test data directory and test result directory use SIC.Test.Helper.Directory and for a example see documentation "Test Unit Programming" section "Test data directory and test result directory"
SOWI Testing programming has two differ write method:
Method: SIC.Test.Helper.Print methods Write
Usage: outside of a test case but inside a test unit (the Log object isn't available)
Output: only output window
Method: this.Log method
Usage: inside of a test case structure (the Log object is availabe)
Output: output window and protocol file
Note: methods has more variants, signature with differ parameters.
The output see into Test Output after run test (see example) and output from the Log object saves additional a protocol file in result directory.
Code example: test programming use SIC.Test.Helper.Print method Write(String).
SIC.Test.Helper.Print.Write(lTest);
SIC.Test.Helper.Print.Write("Method ButtonByAction result: " + lResult);
Test SOWI Web Helper HTML ButtonByAction on 25.04.2017 07:08:28 Method ButtonByAction result: ...
Explanation
Method LineWrite from Debug vs Console
System.Diagnostics.Debug object is the regular Output window in MS Visual Studio (see example) and this method is always available.
Test Console object is the output window of test method and this method isn't always available.
Note to Debug method WriteLine: want see output in the Debug window then run test with "Debug Tests" (context menu, short cut: Ctrl+R, Ctrl+T).
Note to SIC.Test.Helper.Print.Write: this method uses method System.Diagnostics.Debug.WriteLine
See also
SIC.Test.HelperLog all Write methods
Normally doesn't see internal class method. However! The statement: [assembly:InternalsVisibleTo("MyTests")] in ..\Properties\AssemblyInfo.cs file so can seen all methods.
[assembly: InternalsVisibleTo("easyPlanApp.Test")]
Requirement: using System.Runtime.CompilerServices;
Call from SIC.Test.Helper.WebHost method Create(String). This create a web host
/// <summary> /// Test session setting /// Note: object Directory and Log is available. /// </summary> protected override void OnSessionSetting() { SIC.Test.Helper.WebHost.Create(); //* created a HTTP context object * //base.OnSessionSetting(); //* without session token * }
Is Web host running then write the following output
Standard Output:
Debugablaufverfolgung:
HTTP Request URL: http://localhost:49292/
IIS Express running when first start project in Debug mode. Must IIS permanently running then deactivated checkbox "Enable Edit and Continue".
Context menu of IIS Express can start the site.