我的机器人套件具有以下结构
let button = UIButton(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
button.backgroundColor = UIColor.green
button.setTitle("Test Button", for: .normal)
button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
self.view.addSubview(button)
dinesh.robot
S_SUITE
├── datasource.txt
├── dinesh.robot
├── __init__.py
└── test.py
datasource.txt
*** Settings ***
Library test.py
Resource datasource.txt
*** Test Cases ***
DEMO
Log "Testcase start"
sample
Log "Testcase end"
__ init __。py
*** Settings ***
Library __init__.py
test.py
from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn
# These below messages are not seen in debug_record.txt
logger.info('Expected to see this!!!')
logger.error('At least this in debug_record')
def hai():
# These below messages are also not seen in debug_record.txt
BuiltIn().log("this is an info message", "INFO")
logger.info('this is an info too')
hai()
我以
的身份运行此套件from robot.api import logger
def sample():
# Only the below logger.info is added into debug_record.txt
logger.info('THIS IS INSIDE SAMPLE')
当我运行此套件时,单独的消息 robot --loglevel debug --debugfile debug_record.txt S_SUITE/
被添加到THIS IS INSIDE SAMPLE
中。 debug_record.txt
中的datasource.txt
包含dinesh.robot
文件。该文件包含很少的__init__.py
语句,这些语句从未登录到logger.info
中。
除了debug_record.txt
外,我还尝试了logger.info
和logger.error
。但是没有运气。我注意到BuiltIn().log
在控制台中打印错误,并且还将相同的信息发送到logger.error
,但没有发送到log.html
似乎debug_record.txt
仅在测试用例内部(即测试用例运行时)以及套件的logger
使用记录器的地方才向debug_record.txt
添加信息,则不会将信息添加到Resource
。
如何解决此问题?
debug_record.txt:
debug_record.txt
答案 0 :(得分:0)
您的问题有很多方面。但是我认为您在调试文件中看到的是正确的。
1)使用静态库API导入库 当Robot Framework从您的库中找到关键字时,它不会执行代码。相反,Robot Framework使用反射来发现关键字。因此,当您导入静态库时,不会发生日志记录。
但是导入系统很复杂,因此上述情况并不总是正确的。根据所使用的库API以及您是否导入模块或类,关键字的发现以不同的方式发生。例如,如果您导入类并从应该出现在调试文件中的库 init 中进行登录。
2)从未执行的关键字登录。 未执行的关键字不会生成日志记录。
3)从执行关键字登录 如您所说,这已记录下来,并且有望出现在日志文件中。