You are on page 1of 19

Architecture Overview

SOFA Testing
1. iTest
Introduction
2. Get Started
iTest
3. Common
Syntax
4. Best Practices
5. Junit in SOFA WWW.DANA.ID
iTEST Introduction

iTest is an automation framework developed by Alipay. In iTest there are test logic and test data that are
separated.
The test logic is divided into various components.
The test data composed and stored by yaml files and csv files

Interface Test Functional Test UI Test

WWW.DANA.ID
Cont’d
Test case = Test logic + test data
Test Data

Test Logic (Steps)

WWW.DANA.ID
Cont’d

Test Logic Overview

Test logic is stored in a yaml file with the format of filename as


*.logic.yaml
WWW.DANA.ID
Cont’d

Test Data Overview

Test data is stored in a yaml file with


the format of filename as *.data.yaml

WWW.DANA.ID
Get Started iTest

1. To create iTest, we can start it using iTest plugins or create the required files manually.

• Intellij IDEA Edition


online mode :
1) Preferences --> Plugins --> Browse repositories --> manage repositories.
2) add repository by url http://jarvis-storage-file-test.cn-hangzhou.alipay-pub.aliyun-
inc.com/intl/plugin/idea/list.
3) search itesthelper, install it and restart Intellij IDEA.
offline mode:
Preferences --> Plugins --> Install plugin from disk... --> select zip file -->restart

• Eclipse Edition
online mode :
add update site http://jarvis-storage-file-test.cn-hangzhou.alipay-pub.aliyun-
inc.com/intl/plugin/eclipse/itesthelper
offline mode:
Helper --> Install New Software --> Add respository(select zip file ) --> next --> finish -->restart

WWW.DANA.ID
Cont’d

2. To create iTest, we can start it using iTest plugins or create the required files manually.

WWW.DANA.ID
Common Syntax

Logic arrangement in CCIL (Case Component Invoke Language)

CCIL Statement Syntax:

[Variable Component ComponentId [?Param1 = value1 & Param2 =


1 Name =] 2Type : 3 4value2
variable that component type , component Id ,it’s parameters of component, it’s
declared to store it’s required and required and may required but usually not need to be
the result of must be one of be custom declared explicitly because you
component ccprepare,ccmock compent Id , or can prepared this from test data or
invocation and ,ccexec,ccbean,cc ‘beanId.methodN context variables, the params list
can be reused as logic,cccheck,cccl ame’ by ccbean should be consistent with
a context param ear or ‘logicId.dataId’ component method as far as
by other ccil by cclogic possible and the format is like URL
statement other params.
thatn this ccil,
this is optional

Example

WWW.DANA.ID
Cont’d

Common Logic Component & Custom Component

Component type :

Write Custom Component:

1. Create a normal Java class with annotation @CCHost


2. Create a public method with annotation @CCPrepare or @CCMock or @CCExec or @CCCheck or @CCClear
3. Define componentId and description on annotation

result= ccprepare:SamplePrepare?
value=‘Dormamu, I’ve come to bargain’

cccheck:SampleCheck?expectValue=‘abcd’

WWW.DANA.ID
Cont’d

Logic Components – Special Invocations

Component type : `ccbean`


Call the method of spring bean
eg: payResult=ccbean:paymentService.pay
Specify the bundle
eg: payResult=ccbean:paymentService.pay:’com.alipay.ap.cashier.biz.service.impl’

Component type : `cclogic`


Syntax1: cclogic:NM_H_ACQUIRE_ORDER_CREATE
- Only call logic, do not have data
- Inputs incoming parameter list
- Automatically injected from the context by name by default
- Outputs return parameter list
Syntax2:cclogic:NM_H_ACQUIRE_ORDER_CREATE.NM_H_ACQUIRE_ORDER_CREATE_001
- Call logic and use the data, Equivalent to calling a complete test case
- Inputs parameeters will not injected by name by default

WWW.DANA.ID
Cont’d

Data Value Expression


Notes :

Don’t use tab


since
indentation will
represents data
level, same
indent means
the same level,
more indent
means lower
level.

WWW.DANA.ID
Cont’d

Data Value Reference

• Velocity – support velocity syntax to get and set value on data.yaml and logic.yaml
Example:
merchantId: ${merchantId}
userId: $orderCreateRequest.order.seller.userId
orderId: $!vu.get32RandomId()
• !import – import other yaml content to current location
Syntax : !import filepath@key
Example:
envInfo: !import testres/ccprepare/EnvInfo.yaml@default

WWW.DANA.ID
Cont’d

TestCase Execution Starter

BatchTestStarter
1. Scan. Scan and load all *.data.yaml, *.logic.yaml
2. Assemble. Assemble each (dataId, logicId) to TestCase
3. Execute. Execute every TestCase.

SpecificTestStarter
1. Only run the specific testcase in the file resources/testcase/specificTest.list
2. Or run the specific testcase assigned in listTestCases() method

WWW.DANA.ID
Cont’d
TestContext

Each TestCase has a


separated testContext,
it will be active until
the end of run.

WWW.DANA.ID
Cont’d
Best Practice Summarize
• Use plugin to write test case as far as possible, it will help to increase efficiency and reduce
unknown exception and bug.
• Use Standard components which imported by itest-config.xml as far as possible.
• Place all related files (such as logic.yaml 、 data.yaml 、 db-*.csv 、 *.yaml) together inside
testcase catlog like this:

• View test results and analysis test logs on ITest Manage Platform.

WWW.DANA.ID
Junit Test
1. Adding Java class for testing
2. Adding Bean config using xml

Default
location for
Junit test

Default
location for
Bean Config

WWW.DANA.ID
Cont’d
Adding Java class for testing

WWW.DANA.ID
Cont’d
Adding bean config using xml

WWW.DANA.ID

You might also like