testing

Robolectric 3.0 java.lang.NoSuchMethodException on create activity

此生再无相见时 提交于 2019-12-22 08:11:44
问题 I was excited to hear that android studio had made some updates to make unit testing simple to do in android studio so I have been trying to set up roboelectric but I cant get past this error that occurs during the following method. MainActivity = Robolectric.buildActivity(MainActivity.class).create().get(); with the following stacktrace Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: java.lang.Object.attach(android.content.Context, android.app.ActivityThread, android

While building a git project from jenkins it shows an error like couldn't find any revision to build

我只是一个虾纸丫 提交于 2019-12-22 08:06:38
问题 While trying to build a git project through jenkins it gives an error 'ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE' What does this error means and what should I do to remove it? 回答1: I confirm: an empty repo has no HEAD, and no branch. I mention this in "Why do I need to explicitly push a new branch?" That means Jenkins, once the repo is cloned won't be able to checkout a branch (since there is none yet). 来源: https

getActivity() returns a null in my ActivityInstrumentationTestCase2 class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 08:05:11
问题 I want my app to perform the following test in the code with ActivityInstrumentationTestCase2. The problem is the getActivity() method returns a null. This results in a NullPointerException at the line directly underneath the line that contains getActivity(). As a result, the test cannot run. I don't know why it is doing that. I have already tried changing @Before to @Override but the problem continues. Here is the actual Test class: package com.example.guy.smsclassprojecttest; import android

How to log in/out users with Devise in Rails4 testing

一笑奈何 提交于 2019-12-22 07:51:56
问题 I'm trying to ensure proper user access is maintained with Devise in Rails 4, and I'm having a hard time logging a user in in the test suite. The simplest case: require 'test_helper' include Devise::TestHelpers class SiteLayoutTest < ActionDispatch::IntegrationTest def setup @user = users(:test1) end test "logged in should get index" do sign_in @user get users_path assert_response :success assert_select "title", "User Index" end end So far I've not done more really than just implement Devise

Using a custom Application with InstrumentationTestCase

帅比萌擦擦* 提交于 2019-12-22 07:09:18
问题 I have an ActivityInstrumentationTestCase2 (which is a subclass of InstrumentationTestCase). When running my testcases, I need to launch my activities using a custom TestApplication object, since this TestApplication objects has some configuration necessary for my tests. However, I don't see a way to customize my ActivityInstrumentationTestCase2 testcases to use the test Application object. Is there a way to do so? 回答1: I don't know if there's a better way, but I was able to accomplish this

How to test GCM notifications without app?

假装没事ソ 提交于 2019-12-22 06:59:53
问题 I am currently implementing a push functionality using Amazon SNS in my backend. Now, I would like to write tests for the backend and make somehow sure that the published notifications get delivered to the endpoint (GCM mobile device). Is there a way to get a mock registrationID from the Google dev console and check an inbox if any notifications actually arrived? All without ever building an app? 回答1: GCM works also with Chrome. And there's a sample Chrome App available here: https://github

undefined method `use_transactional_fixtures=' in new Rails 3 project

女生的网名这么多〃 提交于 2019-12-22 06:49:06
问题 I am getting an error when trying to run my tests in a Rails3 project, using MongoDB and Mongoid: undefined method `use_transactional_fixtures=' for ActiveSupport::TestCase:Class This is a brand new project running on 3.0.7. My test_helper.rb file is exactly this: ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase self.use_transactional_fixtures = true end Is this an ActiveRecord only method? I do

Are there any automation test example source code using .NET

一笑奈何 提交于 2019-12-22 06:48:37
问题 Are there any source code example of software automation testing with System.Windows.Automation ? because i'm realy having problems with this... 回答1: These links should give you a start: System.Windows.Automation The Microsoft UI Automation Library (MSDN article) 回答2: You might want to look at White. It uses the System.Windows.Automation heavily and includes a lot of samples and tests. 来源: https://stackoverflow.com/questions/4294097/are-there-any-automation-test-example-source-code-using-net

mocha --watch and mongoose models

浪尽此生 提交于 2019-12-22 06:45:41
问题 If I leave mocha watching for changes, every time I save a file mongoose throws the following error: OverwriteModelError: Cannot overwrite Client model once compiled I know that mongoose won't allow to define a model twice, but I don't know how to make it work with mocha --watch . // client.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var clientSchema = new Schema({ secret: { type: String, required: true, unique: true }, name: String, description: String, grant_types:

Rails: test a helper that needs access to the Rails environment (e.g. request.fullpath)

心已入冬 提交于 2019-12-22 06:39:31
问题 I have a helper that accesses request.fullpath . Within an isolated helper test, request is not available. What should I do? Can I somehow mock it or something like that? I'm using the newest versions of Rails and RSpec. Here's what my helper looks like: def item(*args, &block) # some code if request.fullpath == 'some-path' # do some stuff end end So the problematic code line is #4 where the helper needs access to the request object which isn't available in the helper spec. Thanks a lot for