AzurLaneAutoScript icon indicating copy to clipboard operation
AzurLaneAutoScript copied to clipboard

Unit tests based on screenshots | 基于截图的单元测试

Open LmeSzinc opened this issue 2 years ago • 0 comments

你的功能请求是否与问题有关?

Alas 项目越来越大,没有测试要不行了,需要一整个测试框架以满足图片测试的需求。

大世界地图识别测试举例: opsi_test

from module.config.config import AzurLaneConfig
from module.map_detection.os_grid import OSGrid
from module.map_detection.view import *
from module.os.config import OSConfig

file = r'opsi_test.png'

view = View(AzurLaneConfig('template').merge(OSConfig()), mode='os', grid_class=OSGrid)
image = load_image(file)

view.load(image)
view.predict()
view.show()

assert view[node2location('G2')].str == 'FM'
assert view[node2location('E5')].str == 'AK'
assert view[node2location('E6')].str == 'FM'

科研识别测试举例: research_test

from module.base.utils import load_image
from module.config.server import set_server
from module.research.project import research_detect

file = r'research_test.png'
image = load_image(file)

set_server('en')
projects = research_detect(image)

assert str(projects[0]) == 'S2 H-339-MI'
assert str(projects[1]) == 'S4 D-482-RF'
assert str(projects[2]) == 'S2 H-387-MI'
assert str(projects[3]) == 'S4 T-249-MI'  # AssertionError
assert str(projects[4]) == 'S4 G-236-MI'

解决方案

No response

其他内容

No response

LmeSzinc avatar Jun 07 '22 16:06 LmeSzinc