小编Séb*_*nec的帖子

23
推荐指数
1
解决办法
9349
查看次数

如何通过命令提示符和使用Maven的jenkins运行单个黄瓜功能文件?

我对Cucumber/Maven有点新意,因此需要有关运行测试用例的帮助.我使用Cucumber和Selenium在eclipse中开发了一个自动化套件.要运行特定的功能文件/ Junit运行器类,我右键单击Eclipse中的文件并运行它.

但是如何通过命令提示符或Jenkins运行它,通过提供特定命令来运行2-3个功能文件(或)2-3个Junit运行程序类来说50个功能文件或JUnit类?

下面是我在Eclipse中如何构建的包浏览器.

在此输入图像描述

下面是POM.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.perspecsys</groupId>
    <artifactId>salesforce</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>salesforce</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.48.2</version>
        </dependency>

    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

java selenium cucumber jenkins cucumber-jvm

15
推荐指数
2
解决办法
3万
查看次数

在Java中使用泛型为类编写的单元测试是什么?

本文中JpaDao定义的类的非常具体的示例为例:

public abstract class JpaDao<K, E> implements Dao<K, E> {
    protected Class<E> entityClass;

    @PersistenceContext
    protected EntityManager entityManager;

    public JpaDao() {
        ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
        this.entityClass = (Class<E>) genericSuperclass.getActualTypeArguments()[1];
    }

    public void persist(E entity) { entityManager.persist(entity); }

    public void remove(E entity) { entityManager.remove(entity); }

    public E findById(K id) { return entityManager.find(entityClass, id); }
}
Run Code Online (Sandbox Code Playgroud)

最好是为应用程序中的所有现有实体(Order,CustomerBook等)编写单元测试,还是只为一个实体编写单元测试是可以接受的,正如另一个问题所暗示的那样?有关使用泛型的单元测试java类的最佳实践吗?

java generics unit-testing dao jpa

14
推荐指数
1
解决办法
8422
查看次数

Maven:在哪里为tomcat-maven-plugin添加生成的资源?

src/main/webapp我的项目目录中有CSS和JavaScript文件.我想加入这些资源的加入和缩小版本到我的WAR文件和tomcat-maven-plugin拾取它的地方.

我使用yuicompressor-maven-plugin创建文件并将其放入${project.build.directory}/${project.build.finalName}.它适用于maven包,并且这些资源可以用于WAR文件,但不知何故tomcat-maven-plugin根本看不到它们.我应该使用不同的目录吗?

我的pom:

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>tomcat-maven-plugin</artifactId>
            <version>1.1</version>
            <configuration>
                <path>/MyApp</path>
                <warDirectory>${project.build.directory}/${project.build.finalName}</warDirectory>
            </configuration>
        </plugin>
        <plugin>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <optimize>true</optimize>
                <debug>true</debug>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/resources/META-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>META-INF</targetPath>
                        <includes>
                            <include>context.xml</include>
                        </includes>
                    </resource>
                </webResources>
                <archive>
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.3.0</version>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <configuration>
                        <excludes>
                            <exclude>**/*</exclude>
                        </excludes>
                        <aggregations>
                            <aggregation>
                                <output>${project.build.directory}/${project.build.finalName}/js/commons-pack.js</output>
                                <includes>
                                    <include>${project.build.sourceDirectory}/../webapp/js1.js</include> …
Run Code Online (Sandbox Code Playgroud)

java tomcat maven-plugin maven maven-tomcat-plugin

14
推荐指数
1
解决办法
6409
查看次数

使用JUnit同时使用Eclipse和Maven的类路径问题

在JUnit测试中,我使用此代码加载特定于测试的配置文件:

InputStream configFile = getClass().getResourceAsStream("config.xml");
Run Code Online (Sandbox Code Playgroud)

当我通过eclipse运行测试时,它需要xml文件与测试文件位于同一目录中.

当我使用maven构建项目时,它需要xml src/test/resources,因此它被复制到target/test-classes.

如何让它们只用一个文件?

java eclipse junit maven-2

12
推荐指数
1
解决办法
1万
查看次数

Tomcat错误:警告:无法检索容器的JNDI命名上下文

当我尝试在Tomcat 7上启动最近部署的Web应用程序时,我catalina.2013-12-31.logTomcat70/logs/文件夹上的文件中遇到以下错误.

Dec 31, 2013 10:11:20 AM org.apache.catalina.deploy.NamingResources cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/crm]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
    at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:977)
    at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:959)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5483)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1247)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:747)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:222)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) …
Run Code Online (Sandbox Code Playgroud)

java tomcat7

11
推荐指数
5
解决办法
7万
查看次数

类ClassName <:: OtherClassName在Ruby中做什么?

昨天,我在RSpec中找到了以下代码:

class OptionParser < ::OptionParser
Run Code Online (Sandbox Code Playgroud)

这是做什么的?这有什么区别class OptionParser < NameSpace::OptionParser

ruby

9
推荐指数
1
解决办法
210
查看次数

javax.net.ssl.SSLHandshakeException:没有可用的身份验证方案

谷歌揭示了 jdk11.0.2 中的一个错误,但我升级到了 jdk11.0.3,这个错误对我来说仍然存在。重现步骤

  1. git clone https://github.com/deanhiller/webpieces.git
  2. 添加行"org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.3.jdk/Contents/Home"~/.gradle/gradle.properties将 jdk 设置为 11.0.3
  3. ./gradlew :core:core-asyncserver:test从 webpieces 目录运行

测试用例挂起并在日志中显示

Caused by: javax.net.ssl.SSLHandshakeException: No available authentication scheme
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateProducer.onProduceCertificate(CertificateMessage.java:945)
    at java.base/sun.security.ssl.CertificateMessage$T13CertificateProducer.produce(CertificateMessage.java:934)
    at java.base/sun.security.ssl.SSLHandshake.produce(SSLHandshake.java:436)
    at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.goServerHello(ClientHello.java:1224)
    at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.consume(ClientHello.java:1160)
    at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.onClientHello(ClientHello.java:849)
    at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.consume(ClientHello.java:810)
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1065)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1052)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:999)
    at org.webpieces.ssl.impl.AsyncSSLEngine2Impl.createRunnable(AsyncSSLEngine2Impl.java:94)
    ... 12 common frames omitted
Run Code Online (Sandbox Code Playgroud)

我应该提交另一个 JDK bug,还是有人有任何想法?

已解决/相关的 JDK 错误:https://bugs.openjdk.java.net/browse/JDK-8211426

请注意,这会由于某种原因修复它: …

ssl java-11

9
推荐指数
1
解决办法
2万
查看次数

你能在Emacs Lisp宏中创建交互式功能吗?

我正在尝试在emacs lisp中编写一个宏来创建一些"辅助函数".

最终,我的助手功能将比我在这里更有用.我意识到可能有更好/更直观的方法来完成同样的事情(请发帖)但我的基本问题是为什么这不起作用/我做错了什么:

(defmacro deftext (functionname texttoinsert)
  `(defun ,(make-symbol (concatenate 'string "text-" functionname)) ()
     (interactive)
     (insert-string ,texttoinsert)))

(deftext "swallow" "What is the flight speed velocity of a laden swallow?")
(deftext "ni" "What is the flight speed velocity of a laden swallow?")
Run Code Online (Sandbox Code Playgroud)

如果我获取macroexpand的输出并评估它,我得到了我打算用宏获得的交互式函数,但即使宏运行并且似乎评估,我也无法调用M-x text-nitext-swallow.

macros elisp

8
推荐指数
2
解决办法
1874
查看次数

什么是grails.converters.deep.JSON的替代品

grails.converters.deep.JSON似乎现在被弃用了.什么是替代品:

import grails.converters.deep.JSON

print complexObject as JSON
Run Code Online (Sandbox Code Playgroud)

grails serialization json deprecated

8
推荐指数
1
解决办法
3783
查看次数