Click or drag to resize

Testing

The following topics descriptive the SOWI Testing concept.

Programming a test unit go to here (code and example)

Test Driven Development
SOWITesting Web Test Driven Development Environment

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

C#
/// <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);
}
Helper

Uses assembly SIC.Test.Helper for programming test units. This assembly has some helpful function e.g. supported web host for web testing.

SOWIApp Testing Test Unit Test Case

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:

Preparation

Declaration, initialize and setting test data and objects

Execution

Execution test case

Analysis

Check conditions (IsTrue) and report condition results

Construct

Initialize and settings of objects:

Directory
Log
Session
Test Context

Condition

Condition check by method IsTrue. The result is true or false.

Result

Summary of result about conditions.

Clean Up

Test case clean up

See also Test Unit Programming

See also SIC.Test.Helper

Test Name Syntax

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

Test Folder

A example of test project folders shown in Solution Explorer

Screen Test Project 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 support

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.

Create Unit Tests
Class Test Context Properties
Test Protocol (report the test result)

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 M:SIC.Test.Helper.UnitTest.Log.Write(System.String)
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.

Screen Output Test Output

Code example: test programming use SIC.Test.Helper.Print method Write(String).

C#
SIC.Test.Helper.Print.Write(lTest);
SIC.Test.Helper.Print.Write("Method ButtonByAction result: " + lResult);
Output
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

Screen Output Debug Source Code
Screen Output Debug

See also

Testing of Internal Classes and Methods

Normally doesn't see internal class method. However! The statement: [assembly:InternalsVisibleTo("MyTests")] in ..\Properties\AssemblyInfo.cs file so can seen all methods.

C#
[assembly: InternalsVisibleTo("easyPlanApp.Test")]

Requirement: using System.Runtime.CompilerServices;

Web Test Host

Call from SIC.Test.Helper.WebHost method Create(String). This create a web host

C#
/// <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/
Web App running IIS Express

IIS Express running when first start project in Debug mode. Must IIS permanently running then deactivated checkbox "Enable Edit and Continue".

ScreenMSVSProperty Web

Context menu of IIS Express can start the site.

ScreenIISExpress
See Also