Tag: 测试

如何使用不同的包管理Selenium项目代码(如页面对象模型/关键字驱动程序框架)

作为自动化的第一次用户,我正在寻找与自动化项目组织和其他相关内容相关的帮助。 任何人都可以和我一起分享样本项目。 我可以编写脚本,但我无法管理java中的代码。 建议我任何网站的最佳方式。

InjectMocks对象的org.mockito.exceptions.misusing.NotAMockException

我试图模拟一个方法的返回值,但我得到NotAMockException 。 @InjectMocks private MyService myService; @Mock private OtherServiceUsedInMyServiceAsAutowired otherServiceUsedInMyServiceAsAutowired; 在MyService我有一个名为myMethod()的方法,我希望在调用此方法时返回虚拟对象。 doReturn(someDummyObject).when(myService).myMethod(any(), any(), any()); 那时我得到了错误。 我究竟做错了什么? 完整错误: org.mockito.exceptions.misusing.NotAMockException: Argument passed to when() is not a mock! Example of correct stubbing: doThrow(new RuntimeException()).when(mock).someMethod();

如何为jquery自动完成文本字段添加selenium测试覆盖率

我有一个文本字段,jquery自动完成器绑定到它。 HTML JavaScript的 $(‘#autoCompleter’).delegate(“input”, “focus”, AutoCompleter); var AutoCompleter = function(event) { $(this).autocomplete({ source: function(request, response) { jQuery.extAjax({ url: url, data: data, success: response }); }, select: function(event, ui) { if (ui.item.value.match(/^Enter more characters…$/)) { return false; } }, focus: function(event, ui) { if (ui.item.value.match(/^Enter more characters…$/)) { return false; } }, minLength: 2 }); $(this).autocomplete(“search”, […]

在junit测试中获取一个类作为javax.lang.model.element.Element

我想测试我的实用程序类ElementUtils但我不知道如何将类作为元素。 在AnnotationProcessors中,我使用以下代码获取元素 Set elements = roundEnvironment.getElementsAnnotatedWith(annotation); 但由于RoundEnvironment在测试中不可用,因此不能选择。 有没有办法将类作为javax.lang.model.element.Element?

RestEasy:如何validationClientResponse正文?

我有一个REST端点 @GET @Produces(MediaType.APPLICATION_JSON) public Response getVariables(@QueryParam(“_activeonly”) @DefaultValue(“no”) @Nonnull final Active active) { switch(active){ case yes: return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getActiveVariables())).build(); case no: return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getVariables())).build(); } throw new WebApplicationException(Response.Status.BAD_REQUEST); } 返回VariablePresentation List的JSON 。 VariablePresentaion看起来像 @XmlRootElement public class VariablePresentation { private final UUID id; private final String name; private final VariableType type; public VariablePresentation(@Nonnull final Variable variable) { id = […]

挂钩黄瓜检查java中的场景失败

当我在阅读如何为失败的黄瓜场景添加清理时,我在互联网上获得了这段代码。 After do |s| if s.failed? #If you are on an iOS Device $driver.quit sleep(time_for_driver_ready) #else reset end end 这是ruby。 我在java工作,有没有办法实现s.failed? 在java中,因为在java中,after方法声明不包含场景变量。

超时会抛出什么exception?

HTMLUnit中连接超时引发了什么exception?

JUnit:运行一个具有不同配置的测试

我有2种测试方法,我需要使用不同的配置运行它们 myTest() { ….. ….. } @Test myTest_c1() { setConf1(); myTest(); } @Test myTest_c2() { setConf2(); myTest(); } //—————— nextTest() { ….. ….. } @Test nextTest_c1() { setConf1(); nextTest(); } @Test nextTest_c2() { setConf2(); nextTest(); } 我不能从一个配置运行它们(如下面的代码),因为我需要单独的方法来执行tosca。 @Test tests_c1() { setConf1(); myTest() nextTest(); } 我不想写那两个方法来运行每个测试,我该如何解决这个问题? 首先我想写自定义注释 @Test @RunWithBothConf myTest() { …. } 但也许还有其他解决方案吗?

为什么StAX创建XML比DOM慢?

我试图测量StAX和DOM创建两个相同文档所需的时间。 我不知道为什么DOM在创建XML方面更快。 也许我的StAX编写器代码不是很好。 所以这里是StAX(更长的代码) public static final int pocet =100000; try { String encoding = “UTF-8”; XMLOutputFactory f = XMLOutputFactory.newInstance(); XMLStreamWriter w = f.createXMLStreamWriter( new FileOutputStream(subor), encoding); w.writeStartDocument(encoding, “1.0”); w.writeCharacters(“\r\n”); w.writeStartElement(“Noviny”); for (int i = 1; i <= pocet; i++) { w.writeCharacters("\r\n "); w.writeStartElement("Autor"); w.writeCharacters("\r\n "); w.writeStartElement("Id"); String ID = Integer.toString(i); w.writeCharacters(ID); w.writeEndElement(); w.writeCharacters("\r\n "); […]

通过Java独立应用程序运行JMeter测试用例,而无需在本地安装JMeter。

我正在尝试使用以下命令执行JMeter测试用例。 在没有在本地安装JMeter的情况下,我是否有另一种方法来执行测试用例? 在这里,我必须为JMeterUtils提供JMeter HOME路径。 // JMeter Engine StandardJMeterEngine jmeter = new StandardJMeterEngine(); // Initialize Properties, logging, locale, etc. JMeterUtils.loadJMeterProperties(“/path/to/your/jmeter/bin/jmeter.properties”); JMeterUtils.setJMeterHome(“/path/to/your/jmeter”); JMeterUtils.initLogging();// you can comment this line out to see extra log messages of ie DEBUG level JMeterUtils.initLocale(); // Initialize JMeter SaveService SaveService.loadProperties(); // Load existing .jmx Test Plan FileInputStream in = new FileInputStream(“/path/to/your/jmeter/extras/Test.jmx”); HashTree testPlanTree […]