嗨,我有3个javascript文件.
在file1.js我有
jQuery.noConflict()
jQuery(document).ready(function($) {
// ....
});
Run Code Online (Sandbox Code Playgroud)
我得到一个错误'jQuery'在定义之前就被使用了.并且"文档"在定义之前使用.
我如何安全地摆脱这个警告.
如果我做
var document = document || {};
Run Code Online (Sandbox Code Playgroud)
然后在我的utility.js中如果使用它,它将在IE中为null,在Firefox中为ok.
这是什么最好的解决方案?
我使用以下内容.
Powermock-mockito 1.5.12
Mockito 1.95
junit 4.11
Run Code Online (Sandbox Code Playgroud)
这是我的utils类
public void InternalUtils {
public static void sendEmail(String from, String[] to, String msg, String body) {
}
}
Run Code Online (Sandbox Code Playgroud)
这是被测试班级的要点:
public class InternalService {
public void processOrder(Order order) {
if (order.isSuccessful()) {
InternalUtils.sendEmail(...);
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是测试:
@PrepareForTest({InternalUtils.class})
@RunWith(PowerMockRunner.class)
public class InternalService {
public void verifyEmailSend() {
mockStatic(Internalutils.class);
doNothing().when(InternalUtils, "sendEmail", anyString(), any(String.class), anyString(), anyString());
Order order = mock(Order.class);
when(order.isSuccessful()).thenReturn(true);
InternalService is = new InternalService();
verifyStatic(times(1));
is.processOrder(order);
}
}
Run Code Online (Sandbox Code Playgroud)
上述测试失败.给出的验证模式为none,但根据代码,如果订单成功,则必须发送电子邮件.
在文本中匹配完全限定的Java类名称的最佳方法是什么?
例如:java.lang.Reflect,java.util.ArrayList,org.hibernate.Hibernate.
使用字符串生成器而不是纯字符串连接有什么好处和权衡?
new StringBuilder(32).append(str1)
.append(" test: ")
.append(val)
.append(" is changed")
.toString();
Run Code Online (Sandbox Code Playgroud)
vs说
str1 + " test: " + val + " is changed".
Run Code Online (Sandbox Code Playgroud)
str1是一个随机的10个字符串.
str2是一个随机的8个字符串.
嗨,我有以下配置.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.3.v20120416</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在我的jetty-env.xml中我有
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
</Configure>
Run Code Online (Sandbox Code Playgroud)
当我用mvn jetty运行时:运行我得到以下错误.
Caused by: java.lang.ClassNotFoundException: org.mortbay.jetty.webapp.WebAppCont
ext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:92)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClas
s(XmlConfiguration.java:349)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configur
e(XmlConfiguration.java:314)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.jav
a:279)
at org.mortbay.jetty.plugin.AbstractJettyMojo.applyJettyXml(AbstractJett
yMojo.java:449)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMo
jo.java:467)
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
嗨我正在使用maven 3.0.3运行maven测试,使用hibernate 4.0.0最终版本和jdk7 update 2上的spring 3.1.
我收到以下错误.
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63 in method ${myDomainClass}.equals(Ljava/lang/Object;)Z at offset 24
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:352)
at org.hibernate.property.BasicPropertyAccessor.getGetterOrNull(BasicPropertyAccessor.java:331)
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:314)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:250)
at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:314)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:447)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:380)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:320)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:171)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3377)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3369)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3357)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
Run Code Online (Sandbox Code Playgroud)
我的Equals方法使用了commons-lang 2.6中的EqualsBuilder.我设置了以下maven opts
SET MAVEN_OPTS=%MAVEN_OPTS% -XX:-UseSplitVerifier
Run Code Online (Sandbox Code Playgroud)
在阅读了这个 …
我有7个不同的按钮,点击时都执行相同的JavaScript功能.我应该使用类选择器或id选择器.
$("input.printing").on("click", function(event) {
printPdf(event);
});
Run Code Online (Sandbox Code Playgroud)
要么
$("#package1Pdf").click(function(event) {
printPdf(event);
});
$("#package2Pdf").click(function(event) {
printPdf(event);
});
$("#package3Pdf").click(function(event) {
printPdf(event);
});
$("#package4Pdf").click(function(event) {
printPdf(event);
});
Run Code Online (Sandbox Code Playgroud)
每个的优点和缺点是什么?哪个更优选.
我有一个Hudson作业,在远程服务器上执行shell脚本.
它的shell命令是:
/usr/bin/deployWar.sh ${warfileName}
Run Code Online (Sandbox Code Playgroud)
我将此构建标记为参数化,并添加了一个字符串参数:
name: warFileName
default value: none
description: name of war file
Run Code Online (Sandbox Code Playgroud)
当我运行它时,参数被分配,但它被传递到shell脚本.
您好我想知道如何使用Selenium WebDriver点击隐藏元素和/或禁用元素.
我知道硒1我可以这样做,如下所示:
selenium.click(id="idOfHiddenField");
Run Code Online (Sandbox Code Playgroud)
这会有效,但是对于selenium 2(WebDriver),这不行.我不想使用jquery来启用或显示隐藏字段或JavaScript.这是因为大多数测试都使用xpath.
或者我只需要留在旧的硒,这可以让你点击隐藏的字段?
javascript selenium webdriver hidden-field selenium-webdriver
我有以下功能文件: MacroValidation.feature
@macroFilter
Feature: Separating out errors and warnings
Scenario: No errors or warnings when separating out error list
Given I have 0 macros
When I filter out errors and warnings for Macros
Then I need to have 0 errors
And I need to have 0 warnings
Run Code Online (Sandbox Code Playgroud)
我的定义文件.
package com.test.definition;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.runtime.java.StepDefAnnotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.doReturn;
import static org.powermock.api.mockito.PowerMockito.mock; …Run Code Online (Sandbox Code Playgroud) java ×4
javascript ×2
class ×1
cucumber-jvm ×1
equals ×1
hidden-field ×1
hudson ×1
java-7 ×1
jenkins ×1
jetty ×1
jquery ×1
jslint ×1
matching ×1
mockito ×1
performance ×1
regex ×1
selenium ×1
spring-3 ×1
undefined ×1
unit-testing ×1
webdriver ×1