标签: integration-testing

使用Cobertura Maven插件运行集成测试

我无法让Cobertura插件在Maven中运行集成测试.我找到的这个问题最接近的答案是http://jira.codehaus.org/browse/MCOBERTURA-86.但是,这个问题仍然存在漏洞.我在03年4月3日尝试了Stevo建议的配置,它没有用.

我的POM

<reporting>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.3-SNAPSHOT</version>
            <reportSets>
            <reportSet>
                <reports>
                    <report>cobertura-integration</report>
                </reports>
            </reportSet>
            </reportSets>               
        </plugin>   
    </plugins>
</reporting>
Run Code Online (Sandbox Code Playgroud)

这与Stevo提供的配置片段完全相同.

integration-testing maven-2 cobertura

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

Xcode项目如何以编程方式检测目标或如何使用env变量

我想做一个应用程序测试,解析一些json,存储到核心数据,并读出一些对象.

我的代码如何知道它是作为测试或正常运行的一部分运行的?只是某种方式知道"我们是否在测试目标中"?因为应用程序启动它现在启动了一堆请求,用服务器中的信息填充我的coredata.我不希望它在我的测试中这样做.我想启动应用程序,从文件中读取HARDCODED json并使用与coredata相同的方法存储它,并验证结果.

如果有人可以解释如何在每个目标的基础上传递特定的键值对,可以从应用程序中读取,我会更高兴.

configuration integration-testing objective-c xcode4

29
推荐指数
4
解决办法
2万
查看次数

自动化单元测试与自动化集成测试的优缺点是什么?

最近我们一直在为现有的Java应用程序添加自动化测试.

我们有什么

这些测试中的大部分都是集成测试,可能会覆盖一堆调用,如: -

  1. HTTP发布到servlet中
  2. servlet验证请求并调用业务层
  3. 业务层通过hibernate等做了很多东西,并更新了一些数据库表
  4. servlet生成一些XML,通过XSLT运行它以生成响应HTML.

然后,我们验证servlet是否使用正确的XML进行响应,并且数据库中存在正确的行(我们的开发Oracle实例).然后删除这些行.

我们还有一些较小的单元测试,用于检查单个方法调用.

这些测试都是我们夜间(或adhoc)构建的一部分.

问题

这似乎很好,因为我们正在检查系统的边界:一端是servlet请求/响应,另一端是数据库.如果这些工作正常,那么我们就可以自由地重构或混淆其中的任何东西,并且有信心被测试的servlet继续工作.

我们可能会遇到哪些问题?

我看不出如何在单个类上添加更多单元测试会有所帮助.难道这不会让重构变得更难,因为我们更有可能需要抛弃并重新编写测试吗?

integration-testing automated-tests unit-testing

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

"仅在第二次和后续测试中找不到#<User ...>的有效映射"

我正在尝试编写一个请求测试,断言应用程序布局上显示正确的链接,具体取决于用户是登录还是退出.FWIW,我正在使用Devise进行身份验证.

这是我的规格:

require 'spec_helper'
require 'devise/test_helpers'

describe "Layout Links" do
  context "the home page" do
    context "session controls" do
      context "for an authenticated user" do
        before do
          # I know these should all operate in isolation, but I
          # want to make sure the user is explicitly logged out
          visit destroy_user_session_path

          @user = Factory(:user, :password => "Asd123", :password_confirmation => "Asd123")
          @user.confirm!

          # I tried adding this per the Devise wiki, but no change
          @request.env["devise.mapping"] = Devise.mappings[:user]

          # Now log a …
Run Code Online (Sandbox Code Playgroud)

integration-testing devise rspec2 factory-bot

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

如何在使用量角器时运行单个特定的测试用例

我在我的应用程序中使用量角器进行角度js测试,目前有大约19个测试用例,其中一个失败

describe('Login page', function() {

beforeEach(function() {
  browser.ignoreSynchronization = true;
  ptor = protractor.getInstance();
});

it('should contain navigation items', function(){
  //test case code here
});

it('should login the user successfully', function(){ 
  //test case code here
})
});
Run Code Online (Sandbox Code Playgroud)

目前,我运行所有测试用例.但是,如何运行一个测试用例来调试问题,例如一个被描述为"登录页面应该成功登录用户"的问题?

integration-testing angularjs protractor

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

如何在capybara中使用execute_script时返回值?

我在测试中有一个非常简单的行,它调用这样的执行脚本:

puts page.execute_script("return somefunction();").to_i.inspect
Run Code Online (Sandbox Code Playgroud)

在javascript中我有一个这样的函数:

function somefunction(){
    console.log("test");
    return 999;
}
Run Code Online (Sandbox Code Playgroud)

来自控制台日志的"测试"正在注销,因此它正在运行...

在运行测试时查看日志,execute_script返回0而不是999,所以在rspec中我无法获取函数的返回值,如何使page.execute_script从该函数返回该值?

integration-testing rspec ruby-on-rails capybara poltergeist

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

Java,Junit - 捕获标准输入/输出以用于单元测试

我正在使用JUnit编写集成测试来自动测试基于控制台的应用程序.该应用程序是家庭作业,但这部分不是作业.我希望自动化这些测试以提高工作效率 - 我不想再返回并重新测试已经测试过的应用程序部分.(使用单元测试的标准原因)

无论如何,我无法弄清楚或找到关于捕获输出的文章,以便我可以对其进行assertEquals操作,也不提供自动输入.我不在乎输出/输入是否进入控制台/输出窗格.我只需要执行测试并验证输出是否是给定输入的预期.

任何人都有一篇文章或代码来帮助解决这个问题.

java io junit integration-testing

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

Google是否为测试用户提供集成测试

测试用户非常善于进行集成测试.

当我开发facebook oauth启用的东西时,我可以以编程方式创建测试用户并将其用作我的应用程序的真实用户.它们的行为方式与真实用户相同,唯一的区别是它们是沙盒.

Google会提供类似的东西吗?

他们正在将所有服务转移到oauth2,我想与"真实"用户进行完整的集成测试.

目前我手动运行我的集成测试并在请求时授权应用程序,显然这种方法不适合CI和真正的自动化测试.

我看到的唯一选择是创建一个仅在测试中使用的真实帐户,并使用其与硒等内容交互的凭据.

其他选择?

integration-testing google-account oauth-2.0 google-oauth

27
推荐指数
2
解决办法
6190
查看次数

Maven分开单元测试和集成测试

UT =单元测试IT =集成测试.我的所有Integration测试类都使用@Category(IntegrationTest.class)注释

我的目标是:

mvn clean install =>运行UT而不是IT

mvn clean install -DskipTests = true =>不执行任何测试

mvn clean deploy =>运行UT而不是IT

mvn clean test =>运行UT而不是IT

mvn clean verify =>运行UT和IT

mvn clean integration-test =>运行IT并且不执行UT

mvn clean install deploy =>运行UT而不是IT

pom属性:

<junit.version>4.12</junit.version>
<surefire-plugin.version>2.18.1</surefire-plugin.version>
<failsafe-plugin.version>2.18.1</failsafe-plugin.version>
Run Code Online (Sandbox Code Playgroud)
  1. 编译:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <compilerArgument>-Xlint:all</compilerArgument>
            <showWarnings>true</showWarnings>
            <showDeprecation>true</showDeprecation>
        </configuration>
    </plugin>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 单元测试:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
            <excludedGroups>com.xpto.IntegrationTest</excludedGroups>
        </configuration>
    </plugin>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 整合测试:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${failsafe-plugin.version}</version>
        <configuration>
            <groups>com.xpto.IntegrationTest</groups>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>integration-test</goal>
                </goals>
                <configuration>
                    <includes>
                        <include>**/*.class</include>
                    </includes>
                </configuration> …
    Run Code Online (Sandbox Code Playgroud)

integration-testing maven maven-surefire-plugin maven-failsafe-plugin

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

使用Firebase进行单元测试

我正在构建一个Android应用程序,它使用Firebase作为后端和模型,视图,演示者架构.但是,Firebase是一项云服务这一事实使我的Android应用程序中的自动化测试变得复杂.到目前为止,我已经构建了大部分身份验证系统,但我无法看到如何在我的应用中为Firebase代码实现单元测试.在端到端测试方面,我也陷入困境.

由于测试是任何Android应用程序的基础,没有它应用程序开发人员无法确定他们已实现的功能是否按预期运行,如果没有自动化测试,我无法真正进一步发展.

总之,我的问题是:

通常,如何在Android应用程序中实现Firebase自动化测试?

编辑:

作为一个例子,有人可以单独测试以下方法吗?

public void addUser(final String name, final String birthday,
                        final String email, final String password) {
        Firebase mUsersNode = Constants.mRef.child("users");
        final Firebase mSingleUser = mUsersNode.child(name);
        mSingleUser.runTransaction(new Transaction.Handler() {
            @Override
            public Transaction.Result doTransaction(MutableData mutableData) {

                mSingleUser.child("birthday").setValue(birthday);
                mSingleUser.child("email").setValue(email);
                mSingleUser.child("password").setValue(password);
                return Transaction.success(mutableData);
            }

            @Override
            public void onComplete(FirebaseError firebaseError, boolean b, DataSnapshot dataSnapshot) {
                if(firebaseError != null) {
                        mSignUpPresenter.addUserFail(firebaseError);
                    } else {
                        mSignUpPresenter.addUserComplete();
                }
            }
        });
    }
Run Code Online (Sandbox Code Playgroud)

android integration-testing automated-tests unit-testing firebase

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