Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sarah Lottman, SAP September, 2016

Similar presentations


Presentation on theme: "Sarah Lottman, SAP September, 2016"— Presentation transcript:

1 Sarah Lottman, SAP September, 2016
Customer Automated Testing Sarah Lottman, SAP September, 2016

2 Agenda What should be tested OPA5 Qunit

3 Testing in WebIDE

4 Why Test Automation? Reduce manual testing efforts
Automated Tests enable fast feedback cycles • Keep the system running – avoid regressions • Build in quality – submit tested code • Write better code ( loosely coupled code, enables refactoring ) Keep your mainline healthy 为什么要进行测试的自动化? 1. 减少手动测试的时间。 2. 自动化测试能够形成快速的反馈环机制。 2.1 保证系统持续运行在最新状态,避免过多的手动回归测试。 2.2 通过不断提交测试过的代码,改进代码质量 2.3 书写更加健壮的代码(松散耦合,持续重构) 3. 保证主线分支健康

5 Rules and Tools Rules: Don‘t test UI5 framework functionality!
Just test the code in the UI layer Better let a human check the UX and visualization Component Tests QUnit/OPA5 (frontend), ABAP Unit (backend), 为什么要进行测试的自动化? 1. 减少手动测试的时间。 2. 自动化测试能够形成快速的反馈环机制。 2.1 保证系统持续运行在最新状态,避免过多的手动回归测试。 2.2 通过不断提交测试过的代码,改进代码质量 2.3 书写更加健壮的代码(松散耦合,持续重构) 3. 保证主线分支健康 Unit Tests QUnit (frontend), ABAP Unit (backend), Jasmin (HANA content) automated

6 SAPUI5 Application Testing
What Should You Test? Availability of certain controls (example: OnInit) Controller logic, e.g. events Check if the controls appear based on model binding Did Model in backend receive my request? Check if the data is correct What Should You NOT Test? DOM of UI5 controls (not API) All properties of a control, only the most relevant UI5 framework functionality 这个页面主要介绍了这些规则的具体体现。 1. 具体某个控件是否可以获得,包括可视性,可操作性等。 2. 控件的逻辑,触发的行为 3. 检查控件的基于数据绑定的表现,比如数据的展示是否和预期一致。 4. 检查模型后台数据的请求和发送是否和预期一致。 5. 检查数据的正确性。 不应该测试的内容: UI5 控件的DOM 控件的所有属性 UI5框架的功能

7 OPA5

8 What’s OPA? OPA5 is an API for SAPUI5 controls. It hides asynchronicity and eases access to SAPUI5 elements. This makes OPA5 especially helpful for testing user interactions, integration with SAPUI5, navigation, and data binding. The OPA5 library is JavaScript-based. This means that you can write your tests in the same language in which your app is written. TDD (Testing Driven-Development, the pattern is Given, When, Then)

9 OPA5 and SAPUI5 Limitation of OPA Advantages of OPA tests
Screen capturing Testing across more than one page Remote test execution End-to-end tests are not recommended with OPA due to authentication issues and fragility of test data Advantages of OPA tests Integration tests implemented in same programing language as application No need to learn an additional programing language (Java – for the Selenium tests) Test execution is faster than with Selenium Tests are executed in the same way as unit QUnit tests Work well with mock data from the SAP UI5 Mock Server Things to consider implementing OPA tests Investing in reusable OPA5 artefacts for usage within application tests (similar to Selenium page objects) Having solid mock data in good quality 优点 OPA5是JS实现的,所以对于Fiori 或者UI5的项目,编程语言是一致的。方便测试代码的调用和集成,debug。 语言一致,所以基本不需要学习额外的语言。 使用异步模式,执行速度比Selenium, 以我个人的观点,还是比较慢的。特别是在debug模式下 和QUnit测试执行的方法基本一致。后面附录部分有一页链接专门说明如何运行的。 通过Mock Data可以和Mock Server一起工作得很好 支持TDD和BDD的测试方法 局限: 不支持屏幕捕获 无法支持多个页面同时测试 (少部分可以支持2个页面,比如launchpad 选择tile 跳转到app) 无法进行远程执行 E2E 不推荐使用OPA 主要考虑是认证和测试数据的不稳定性 所以一般使用Mock Server 的方式进行 实现OPA 测试需要考虑的设计问题 将可复用的一些方法集成到common中 为了保证测试的稳定性使用mock data 使用iframe支持在url中使用参数, hash测试用到。

10 QUnit QUnit is a framework for unit testing JavaScript code
From jQuery open source project Used by jQuery, SAP UI5, . . . Supports asynchronous tests Provides stand-alone test runner or integrates with SAPUI5 CI environment Included in SAP UI5 distribution

11 QUnit Example QUnit.module("Calculator", { setup : function() {
this.calculator = new }, teardown : function() {} }); // Calculator(); // in the future beforeEach Executed before each test // in the future afterEach case QUnit.test("show zero initially", function(assert) { assert.equal(this.calculator.display(), 0); }); QUnit.test("display entered digit", function(assert) { this.calculator.press("1"); assert.equal(this.calculator.display(), 1); });

12 Basic Assertion Toolkit
assert.ok(1, "1 should have been truthy"); assert.ok(!false, "!false should have been truthy"); assert.equal(1 + 1, 2, "1+1 should have equaled 2"); assert.equal(1, true, "1 should have been converted to assert.strictEqual("there", "there"); true"); assert.notEqual(Math.PI, ); assert.notEqual({}, {}); assert.notStrictEqual(1, "1"); assert.deepEqual({}, {}); assert.deepEqual([1, 2], [1, 2]); assert.notDeepEqual({ f : "this" }, { f : "that" }); assert.throws(function() { "anna".reverse(); }, TypeError, "function should have thrown TypeError");

13 QUnit Test Runner

14 Thank you

15

16

17 The Grid Drawing area Headline area White space


Download ppt "Sarah Lottman, SAP September, 2016"

Similar presentations


Ads by Google