当前位置: 首页 > news >正文

php源码项目 门户网站开发网站建设实习生怎么样

php源码项目 门户网站开发,网站建设实习生怎么样,wordpress网站防护,南漳网站设计前言 在现代软件开发中,测试自动化是确保软件质量和稳定性的核心手段之一。随着开发周期的缩短和功能模块的增多,手动测试逐渐无法满足高效性和准确性的需求。因此,测试人员需要依赖自动化工具来提升测试效率,减少人为干预和错误。…

前言

  在现代软件开发中,测试自动化是确保软件质量和稳定性的核心手段之一。随着开发周期的缩短和功能模块的增多,手动测试逐渐无法满足高效性和准确性的需求。因此,测试人员需要依赖自动化工具来提升测试效率,减少人为干预和错误。

  本文将介绍一款基于 Bash 脚本的简单自动化测试工具,它旨在帮助测试人员高效地管理和执行多种测试任务。这个脚本不仅能在命令行下交互式地进行模块选择,还能根据实际测试结果显示通过或失败的状态,方便测试人员快速识别问题。

一、目录结构

test/
├── config.conf
├── scripts/
│   └── eth.sh
└── tools/
└── xxx_test_scripts.sheth.sh: 当前示例脚本,一个sh脚本写一个测试功能,所有测试脚本都放在scripts目录下;
xxx_test_scripts.sh: 这是框架的主脚本,包含多个可选的测试模块,用户可以根据需要选择并执行某个具体的功能测试;
config.conf: 配置文件,用于存储全局配置、测试项启用状态以及其他参数;
tools/: 存放工具或素材,用于扩展框架的功能。

二、代码

1、config.conf

# ====== 0 代表启用测试项,1 代表不启用测试项 ======
example1_activation=0
example2_activation=0
example3_activation=0# ====== 其它功能配置 ======
test=888

2、eth.sh

#!/bin/bash# 获取当前脚本所在的目录
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
echo "Current script directory: ${SCRIPT_DIR}"# 返回到上级目录
PARENT_DIR=$(dirname "$SCRIPT_DIR")
echo "Parent directory: ${PARENT_DIR}"# 加载上级目录中的配置文件
source ${PARENT_DIR}/config.conf
echo "${test}"test_eth() {eth_status="$1"if ! ip link show "$eth_status" | grep -q "state UP"; thenexit 1 # 失败时退出,返回 1elseexit 0 # 成功时退出,返回 0fi
}test_eth "$1"

3、xxx_test_scripts.sh

#!/bin/bash# 获取当前脚本所在的目录
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)# 检查 config.conf 是否存在
if [[ ! -f "${SCRIPT_DIR}/config.conf" ]]; thenecho "config.conf not found!"exit 1
fi# 加载配置文件
source ${SCRIPT_DIR}/config.confEXAMPLE1_RESULT=0
EXAMPLE2_RESULT=0
EXAMPLE3_RESULT=0# 依赖软件安装
install() {if ! command -v figlet > /dev/null 2>&1; thenecho "Writing the installation method."fi
}test_example1() {read -p "example1 test results(y: pass - n: fail): " example1if [[ "${example1}" == "N" ]] || [[ "${example1}" == "n" ]]; thenEXAMPLE1_RESULT=1echo -e "####################\033[31m example1:      fail \033[0m#####################"echo "##############################################################"elseEXAMPLE1_RESULT=0echo -e "####################\033[32m example1:      pass \033[0m#####################"echo "##############################################################"fi
}test_example2() {read -p "example2 test results(y: pass - n: fail): " example2if [[ "${example2}" == "N" ]] || [[ "${example2}" == "n" ]]; thenEXAMPLE2_RESULT=1echo -e "####################\033[31m example2:      fail \033[0m#####################"echo "##############################################################"elseEXAMPLE2_RESULT=0echo -e "####################\033[32m example2:      pass \033[0m#####################"echo "##############################################################"fi
}test_example3() {sudo chmod 777 ${SCRIPT_DIR}/scripts/eth.shsudo ${SCRIPT_DIR}/scripts/eth.sh eth0if [[ $? -eq 0 ]]; thenEXAMPLE3_RESULT=0echo -e "####################\033[32m example3:      pass \033[0m#####################"echo "##############################################################"elseEXAMPLE3_RESULT=1echo -e "####################\033[31m example3:      fail \033[0m#####################"echo "##############################################################"fi
}test_exit() {exit 11
}module_choice() {echo " "echo "**************** Test Module Selection (Failures Detected) ****************"echo " 0 (exit                              test)"if [[ ${example1_activation} == "0" ]]; thenif [[ ${EXAMPLE1_RESULT} -eq 0 ]]; thenecho -e " 1 (example1                          test) [\033[32m pass \033[0m]"elseecho -e " 1 (example1                          test) [\033[31m fail \033[0m]"fifiif [[ ${example2_activation} == "0" ]]; thenif [[ ${EXAMPLE2_RESULT} -eq 0 ]]; thenecho -e " 2 (example2                          test) [\033[32m pass \033[0m]"elseecho -e " 2 (example2                          test) [\033[31m fail \033[0m]"fifiif [[ ${example3_activation} == "0" ]]; thenif [[ ${EXAMPLE3_RESULT} -eq 0 ]]; thenecho -e " 3 (example3                          test) [\033[32m pass \033[0m]"elseecho -e " 3 (example3                          test) [\033[31m fail \033[0m]"fifiecho " R (Failure item                      test)"echo "***************************************************************************"read -p "please select a test module to rerun or exit: " MODULE_CHOICE
}module_test() {MODULE_CHOICE=$(echo "$MODULE_CHOICE" | tr '[:upper:]' '[:lower:]')case ${MODULE_CHOICE} in0)test_exit;;1)if [[ ${example1_activation} == "0" ]]; thentest_example1fi;;2)if [[ ${example2_activation} == "0" ]]; thentest_example2fi;;3)if [[ ${example3_activation} == "0" ]]; thentest_example3fi;;r)# Failure item选项,重新测试所有失败的项if [[ ${EXAMPLE1_RESULT} -eq 1 ]]; thentest_example1fiif [[ ${EXAMPLE2_RESULT} -eq 1 ]]; thentest_example2fiif [[ ${EXAMPLE3_RESULT} -eq 1 ]]; thentest_example3fi;;# *)# echo "Invalid choice. Please try again."# ;;esac
}check_all_pass() {local test_results=(${EXAMPLE1_RESULT}${EXAMPLE2_RESULT}${EXAMPLE3_RESULT})all_zero=true# 如果有一个结果等于1,标记为falsefor all_result in "${test_results[@]}"; doif [[ "${all_result}" -eq 1 ]]; thenall_zero=falsebreakfidone# 获取全部测试结果 0通过 1不通过if [[ "$all_zero" == true ]]; thenreturn 0  # 返回0表示所有结果为0elsereturn 1  # 返回1表示至少有一个结果不为0fi
}test_single() {while true; domodule_choicemodule_testcheck_all_passif [[ $? -eq 0 ]]; thenecho "****************************************************************"echo -e "\033[32m$(figlet "PASS")\033[0m"echo "****************************************************************"breakfisleep 1done
}test_all() {echo " "echo "******************** Test Execution Started ********************"echo "****************************************************************"echo " "if [[ ${example1_activation} == "0" ]]; thentest_example1sleep 1fiif [[ ${example2_activation} == "0" ]]; thentest_example2sleep 1fiif [[ ${example3_activation} == "0" ]]; thentest_example3sleep 1fiecho " "echo " "echo "********************* Test Results Summary *********************"echo "****************************************************************"if [[ ${example1_activation} == "0" ]]; thenif [[ ${EXAMPLE1_RESULT} -eq 0 ]]; thenecho -e "example1:                       \033[32m pass \033[0m"elseecho -e "example1:                       \033[31m fail \033[0m"fifiif [[ ${example2_activation} == "0" ]]; thenif [[ ${EXAMPLE2_RESULT} -eq 0 ]]; thenecho -e "example2:                       \033[32m pass \033[0m"elseecho -e "example2:                       \033[31m fail \033[0m"fifiif [[ ${example3_activation} == "0" ]]; thenif [[ ${EXAMPLE3_RESULT} -eq 0 ]]; thenecho -e "example3:                       \033[32m pass \033[0m"elseecho -e "example3:                       \033[31m fail \033[0m"fifiecho " "check_all_passif [[ $? -eq 0 ]]; thenecho "****************************************************************"echo -e "\033[32m$(figlet "PASS")\033[0m"echo "****************************************************************"elseecho "****************************************************************"echo -e "\033[31m$(figlet "FAIL")\033[0m"echo "****************************************************************"echo " " echo " "fi
}send_result() {echo "Upload test results."
}main() {installtest_allcheck_all_passif [[ $? -eq 1 ]]; thentest_singlefisend_result
}main

注释:文件必须 Unix(LF) 格式 ,可用通过 notepad++ 转换

http://www.yayakq.cn/news/379511/

相关文章:

  • 成品网站nike源码免费网站免费一站二站四站
  • 亚马逊雨林生存游戏上海推广seo
  • 1 高端品牌网站定制网站备案要网站做才可以使用吗
  • 东营市河口区建设局网站怎么建设公司网站信息
  • 工程门户网站建设山东免费网站制作
  • 响应式网站样式图怎么做学ui设计的培训班费用是多少
  • 电商网站 知名案例长沙网站设计公司重庆标志
  • 湖北营销网站建设设计wordpress 分类目录函数
  • 如何查询网站的建站工具厦门人才网唯一官方网站登录入口
  • 网站开发工程师分析深圳西丽网站建设
  • 一个网站做十个二级域名怎么做移动网站吗
  • 怎么做钓鱼网站企业网站系统那个好
  • 做视频网站 带宽计算懂得做网站还可以做什么兼职
  • 工信和信息化部网站网页设计尺寸规范ps
  • 企业宣传网站系统建设方案网站怎么做二级域名
  • 中山模板建站软件wordpress页面发布失败为什么
  • 企业做网站哪个最好怎么快速提升网站权重
  • 石家庄城乡建设局网站6dw网站怎么做跳转
  • 公装设计网站网站的设计思路范文
  • 快速制作网站的方法php做网站如何配置域名的
  • 国企网站建设需要注意网站设计和营销
  • 厦门海绵城市建设官方网站深圳哪家网站设计比较好
  • 西安的网站建设网站阿里云使用wordpress
  • 免费网站制作多少钱简述网站建设基本过程
  • 网站制作模板免费下载wordpress 文章页404
  • 舟山外贸营销网站建站南部网站建设
  • 温县住房和城乡建设局网站网站流量查询服务平台
  • 公司网站免费建设大学的网站设计
  • 建云购网站wordpress区块 宽度
  • 网页版微信扫一扫在哪长沙seo咨询