中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

Web场景用例

以Nginx为例,编写功能测试用例。

#! /bin/bash
##################################
# 功能描述: 云测试平台功能性测试案例
# 版本信息: 华为技术有限公司,版权所有(C) 2020-2021
# 修改记录:2021-12-05 修改
# 案例软件为:Nginx
# 预置条件:
#   1. Nginx已安装并启动。
#   2. Nginx已配置好SSL证书并监测443端口
#   3. 80,443端口处于开发状态
##################################
# 测试用例一:测试HTTP功能
testHttp() {
  result=`curl -k http://127.0.0.1/index.html`
  if [[ "$result" =~ "Welcome to" ]];then
    assertTrue true
  else
    assertTrue "'$result' not contain 'Welcome to'" false
  fi
}
# 测试用例二:测试HTTPS功能
testHttps() {
  result=`curl -k https://127.0.0.1/index.html`
  if [[ "$result" =~ "Welcome to" ]];then
    assertTrue true
  else
    assertTrue "'$result' not contain 'Welcome to'" false
  fi
}
# Load and run sUnit2.
. ../shunit2