修复执行完测试后生成报告位置错误问题

This commit is contained in:
汪杰 2023-05-24 16:17:35 +08:00
parent 45ebb55c58
commit 36a36f41db
40 changed files with 5 additions and 526 deletions

View File

@ -37,14 +37,14 @@ def pytest_sessionstart():
def pytest_sessionfinish(session, exitstatus): def pytest_sessionfinish(session, exitstatus):
"""运行完成后生成allure报告文件再将本地启动方式放入该目录下""" """运行完成后生成allure报告文件再将本地启动方式放入该目录下"""
# allure报告展示environment时所需要的数据这里是在项目根路径下创建的environment.properties文件拷贝到allure-report报告中,保证环境文件不会被清空 # allure报告展示environment时所需要的数据这里是在项目根路径下创建的environment.properties文件拷贝到allure-report报告中,保证环境文件不会被清空
shutil.copy(BASE_DIR+'/environment.properties',BASE_DIR+ '/Temp/environment.properties') shutil.copy(BASE_DIR + '/environment.properties', BASE_DIR + '/Temp/environment.properties')
# allure报告展示运行器时所需要的数据 # allure报告展示运行器时所需要的数据
shutil.copy(BASE_DIR+'/executor.json', BASE_DIR+'/Temp/executor.json') shutil.copy(BASE_DIR + '/executor.json', BASE_DIR + '/Temp/executor.json')
# 使用allure generate -o 命令将./Temp目录下的临时报告导出到TestReport目录 # 使用allure generate -o 命令将./Temp目录下的临时报告导出到TestReport目录
os.system('allure generate ./Temp -o ./outFiles/report --clean') os.system(f'allure generate {BASE_DIR}/Temp -o {BASE_DIR}/outFiles/report --clean')
# 将本地启动脚本和查看allure报告方法放入报告目录下面 # 将本地启动脚本和查看allure报告方法放入报告目录下面
shutil.copy(BASE_DIR+'/open_report.sh', BASE_DIR+'/outFiles/report/open_report.sh') shutil.copy(BASE_DIR + '/open_report.sh', BASE_DIR + '/outFiles/report/open_report.sh')
shutil.copy(BASE_DIR+'/查看allure报告方法', BASE_DIR+'/outFiles/report/查看allure报告方法') shutil.copy(BASE_DIR + '/查看allure报告方法', BASE_DIR + '/outFiles/report/查看allure报告方法')
def pytest_collection_modifyitems(items) -> None: def pytest_collection_modifyitems(items) -> None:

View File

@ -1,29 +0,0 @@
# !/usr/bin/python
# -*- coding:utf-8 -*-
# @Time : 2023/5/9 15:40
# @Author : wangjie
# @File : device_center.py
# @project : SensoroApi
from common.base_api import BaseApi
class DeviceCenter(BaseApi):
"""设备中心相关接口"""
def get_devices_list(self, headers=None, params=None):
"""获取设备列表"""
address = '/device/v1/deviceCenter/devices'
headers = headers
params = params
return self.get(address=address, headers=headers, params=params)
if __name__ == '__main__':
params = {
'page': 1,
'size': 20
}
r = DeviceCenter().get_devices_list(params=params)
print(BaseApi.get_json(r))

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
{
"uid" : "b1a8273437954620fa374b796ffaacdd",
"children" : [ ],
"name" : "behaviors"
}

View File

@ -1,5 +0,0 @@
{
"uid" : "4b4757e66a1912dae1a509f688f20b0f",
"children" : [ ],
"name" : "categories"
}

View File

@ -1,5 +0,0 @@
{
"uid" : "83edc06c07f9ae9e47eb6dd1b683e4e2",
"children" : [ ],
"name" : "packages"
}

View File

@ -1,5 +0,0 @@
{
"uid" : "98d3104e051c652961429bf95fa0b5d6",
"children" : [ ],
"name" : "suites"
}

View File

@ -1,5 +0,0 @@
{
"uid" : "ab17fc5a4eb3bca4b216b548c7f9fcbc",
"children" : [ ],
"name" : "timeline"
}

View File

@ -1,11 +0,0 @@
launch_status failed=0 1684311565000000000
launch_status broken=0 1684311565000000000
launch_status passed=0 1684311565000000000
launch_status skipped=0 1684311565000000000
launch_status unknown=0 1684311565000000000
launch_time duration=0 1684311565000000000
launch_time min_duration=0 1684311565000000000
launch_time max_duration=0 1684311565000000000
launch_time sum_duration=0 1684311565000000000
launch_retries retries=0 1684311565000000000
launch_retries run=0 1684311565000000000

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Allure Report summary mail</title>
</head>
<body>
Mail body
</body>
</html>

View File

@ -1,11 +0,0 @@
launch_status_failed 0
launch_status_broken 0
launch_status_passed 0
launch_status_skipped 0
launch_status_unknown 0
launch_time_duration 0
launch_time_min_duration 0
launch_time_max_duration 0
launch_time_sum_duration 0
launch_retries_retries 0
launch_retries_run 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,3 +0,0 @@
[ {
"data" : { }
} ]

View File

@ -1,3 +0,0 @@
[ {
"data" : { }
} ]

View File

@ -1,10 +0,0 @@
[ {
"data" : {
"failed" : 0,
"broken" : 0,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 0
}
} ]

View File

@ -1 +0,0 @@
{ }

View File

@ -1,6 +0,0 @@
[ {
"data" : {
"run" : 0,
"retry" : 0
}
} ]

View File

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>Allure Report</title>
<link rel="favicon" href="favicon.ico?v=2">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="plugins/screen-diff/styles.css">
</head>
<body>
<div id="alert"></div>
<div id="content">
<span class="spinner">
<span class="spinner__circle"></span>
</span>
</div>
<div id="popup"></div>
<script src="app.js"></script>
<script src="plugins/behaviors/index.js"></script>
<script src="plugins/packages/index.js"></script>
<script src="plugins/screen-diff/index.js"></script>
</body>
</html>

View File

@ -1,108 +0,0 @@
'use strict';
allure.api.addTranslation('en', {
tab: {
behaviors: {
name: 'Behaviors'
}
},
widget: {
behaviors: {
name: 'Features by stories',
showAll: 'show all'
}
}
});
allure.api.addTranslation('ru', {
tab: {
behaviors: {
name: 'Функциональность'
}
},
widget: {
behaviors: {
name: 'Функциональность',
showAll: 'показать все'
}
}
});
allure.api.addTranslation('zh', {
tab: {
behaviors: {
name: '功能'
}
},
widget: {
behaviors: {
name: '特性场景',
showAll: '显示所有'
}
}
});
allure.api.addTranslation('de', {
tab: {
behaviors: {
name: 'Verhalten'
}
},
widget: {
behaviors: {
name: 'Features nach Stories',
showAll: 'Zeige alle'
}
}
});
allure.api.addTranslation('he', {
tab: {
behaviors: {
name: 'התנהגויות'
}
},
widget: {
behaviors: {
name: 'תכונות לפי סיפורי משתמש',
showAll: 'הצג הכול'
}
}
});
allure.api.addTranslation('br', {
tab: {
behaviors: {
name: 'Comportamentos'
}
},
widget: {
behaviors: {
name: 'Funcionalidades por história',
showAll: 'Mostrar tudo'
}
}
});
allure.api.addTab('behaviors', {
title: 'tab.behaviors.name', icon: 'fa fa-list',
route: 'behaviors(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)',
onEnter: (function (testGroup, testResult, testResultTab) {
return new allure.components.TreeLayout({
testGroup: testGroup,
testResult: testResult,
testResultTab: testResultTab,
tabName: 'tab.behaviors.name',
baseUrl: 'behaviors',
url: 'data/behaviors.json',
csvUrl: 'data/behaviors.csv'
});
})
});
allure.api.addWidget('widgets', 'behaviors', allure.components.WidgetStatusView.extend({
rowTag: 'a',
title: 'widget.behaviors.name',
baseUrl: 'behaviors',
showLinks: true
}));

View File

@ -1,64 +0,0 @@
'use strict';
allure.api.addTranslation('en', {
tab: {
packages: {
name: 'Packages'
}
}
});
allure.api.addTranslation('ru', {
tab: {
packages: {
name: 'Пакеты'
}
}
});
allure.api.addTranslation('zh', {
tab: {
packages: {
name: '包'
}
}
});
allure.api.addTranslation('de', {
tab: {
packages: {
name: 'Pakete'
}
}
});
allure.api.addTranslation('he', {
tab: {
packages: {
name: 'חבילות'
}
}
});
allure.api.addTranslation('br', {
tab: {
packages: {
name: 'Pacotes'
}
}
});
allure.api.addTab('packages', {
title: 'tab.packages.name', icon: 'fa fa-align-left',
route: 'packages(/)(:testGroup)(/)(:testResult)(/)(:testResultTab)(/)',
onEnter: (function (testGroup, testResult, testResultTab) {
return new allure.components.TreeLayout({
testGroup: testGroup,
testResult: testResult,
testResultTab: testResultTab,
tabName: 'tab.packages.name',
baseUrl: 'packages',
url: 'data/packages.json'
});
})
});

View File

@ -1,97 +0,0 @@
(function () {
var settings = allure.getPluginSettings('screen-diff', {diffType: 'diff'});
function renderImage(src) {
return '<div class="screen-diff__container">' +
'<img class="screen-diff__image" src="data/attachments/' + src + '">' +
'</div>';
}
function renderDiffContent(type, data) {
function findImage(name) {
if (data.testStage && data.testStage.attachments) {
return data.testStage.attachments.filter(function (attachment) {
return attachment.name === name;
})[0];
}
return null;
}
var diffImage = findImage('diff');
var actualImage = findImage('actual');
var expectedImage = findImage('expected');
if (!diffImage && !actualImage && !expectedImage) {
return '<span>Diff, actual and expected image have not been provided.</span>';
}
if (type === 'diff') {
if (!diffImage) {
return renderImage(actualImage.source);
}
return renderImage(diffImage.source);
}
if (type === 'overlay') {
return '<div class="screen-diff__overlay screen-diff__container">' +
'<img class="screen-diff__image" src="data/attachments/' + expectedImage.source + '">' +
'<div class="screen-diff__image-over">' +
'<img class="screen-diff__image" src="data/attachments/' + actualImage.source + '">' +
'</div>' +
'</div>';
}
}
var ScreenDiffView = Backbone.Marionette.View.extend({
className: 'pane__section',
events: {
'click [name="screen-diff-type"]': 'onDiffTypeChange',
'mousemove .screen-diff__overlay': 'onOverlayMove'
},
templateContext: function () {
return {
diffType: settings.get('diffType')
}
},
template: function (data) {
var testType = data.labels.filter(function (label) {
return label.name === 'testType'
})[0];
if (!testType || testType.value !== 'screenshotDiff') {
return '';
}
return '<h3 class="pane__section-title">Screen Diff</h3>' +
'<div class="screen-diff__content">' +
'<div class="screen-diff__switchers">' +
'<label><input type="radio" name="screen-diff-type" value="diff"> Show diff</label>' +
'<label><input type="radio" name="screen-diff-type" value="overlay"> Show overlay</label>' +
'</div>' +
renderDiffContent(data.diffType, data) +
'</div>';
},
adjustImageSize: function (event) {
var overImage = this.$(event.target);
overImage.width(overImage.width());
},
onRender: function () {
const diffType = settings.get('diffType');
this.$('[name="screen-diff-type"][value="' + diffType + '"]').prop('checked', true);
if (diffType === 'overlay') {
this.$('.screen-diff__image-over img').on('load', this.adjustImageSize.bind(this));
}
},
onOverlayMove: function (event) {
var pageX = event.pageX;
var containerScroll = this.$('.screen-diff__container').scrollLeft();
var elementX = event.currentTarget.getBoundingClientRect().left;
var delta = pageX - elementX + containerScroll;
this.$('.screen-diff__image-over').width(delta);
},
onDiffTypeChange: function (event) {
settings.save('diffType', event.target.value);
this.render();
}
});
allure.api.addTestResultBlock(ScreenDiffView, {position: 'before'});
})();

View File

@ -1,26 +0,0 @@
.screen-diff__switchers {
margin-bottom: 1em;
}
.screen-diff__switchers label + label {
margin-left: 1em;
}
.screen-diff__overlay {
position: relative;
cursor: col-resize;
}
.screen-diff__container {
overflow-x: auto;
}
.screen-diff__image-over {
top: 0;
left: 0;
bottom: 0;
background: #fff;
position: absolute;
overflow: hidden;
box-shadow: 2px 0 1px -1px #aaa;
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +0,0 @@
{
"total" : 0,
"items" : [ ]
}

View File

@ -1,3 +0,0 @@
[ {
"data" : { }
} ]

View File

@ -1,4 +0,0 @@
{
"total" : 0,
"items" : [ ]
}

View File

@ -1,3 +0,0 @@
[ {
"data" : { }
} ]

View File

@ -1 +0,0 @@
[ ]

View File

@ -1 +0,0 @@
[ ]

View File

@ -1,10 +0,0 @@
[ {
"data" : {
"failed" : 0,
"broken" : 0,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 0
}
} ]

View File

@ -1 +0,0 @@
[ ]

View File

@ -1,6 +0,0 @@
[ {
"data" : {
"run" : 0,
"retry" : 0
}
} ]

View File

@ -1 +0,0 @@
[ ]

View File

@ -1,4 +0,0 @@
{
"total" : 0,
"items" : [ ]
}

View File

@ -1,13 +0,0 @@
{
"reportName" : "Allure Report",
"testRuns" : [ ],
"statistic" : {
"failed" : 0,
"broken" : 0,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 0
},
"time" : { }
}