tdd

Eclipse: bind some key for all unit tests

…衆ロ難τιáo~ 提交于 2019-12-22 02:01:54
问题 I practice TDD and run my tests very often. Eclipse has a nice command to run the last-launched configuration. But when I invoke the command in some unit test class, Eclipse runs only the tests for current unit test class. I want run all my unit tests instead. Yes, I can use the mouse to invoke the command that runs all JUnit tests, but, to repeat: I run tests very often. 回答1: You need to change eclipse's run mode. By default, it will try to run whatever is selected or being edited. You want

Testing User Model (Devise Authentication) with MiniTest

 ̄綄美尐妖づ 提交于 2019-12-21 22:38:38
问题 I'm trying to test user model, for which I've devise authentication. The problem I'm facing is, 1. Having 'password'/'password_confirmation' fields in fixtures is giving me invalid column 'password'/'password_confirmation' error. If I remove these columns from fixture and add in user_test.rb require 'test_helper' class UserTest < ActiveSupport::TestCase def setup @user = User.new(name: "example user", email: "example@example.com", password: "Test123", work_number: '1234567890', cell_number:

Breaking a local dependency to unit test a void method

让人想犯罪 __ 提交于 2019-12-21 20:55:46
问题 I am practicing with mockito, but I am a bit stuck on how to test a method that depends on a call to method in a local object. See the following example: public class Worker { public void work() { Vodka vodka = new Vodka(); vodka.drink(); } } This worker, instead of doing his job, he likes drinking. But I want to add a test to prove that he drinks while he works. But there is no way of doing so, because I must verify that the method drink() is called when the method work is called. I think

How far can you go with JavaScript testing?

不打扰是莪最后的温柔 提交于 2019-12-21 20:16:13
问题 I'm somewhat informed with TDD and BDD with Ruby/Rails, but I will eventually need to use some form of testing with my JavaScript code. I use MooTools as a JS framework and I absolutely love how well I can organize and modularize my code with its codebase. But, sometimes, when I add new features to my application, I find that the functionality can easily break from how it worked before. When it comes to testing JavaScrtpt code, does the testing itself fall short of user interaction? Is it

How to debug in Visual Studio with NSpec

回眸只為那壹抹淺笑 提交于 2019-12-21 19:45:27
问题 how do I debug in visual studio with NSpec? I've resharper installed I need to step into my test code. 回答1: At least in Visual Studio 2013, the NSpec Test Adapter (by {o} Software) seems to do the trick. Find it in the Extensions gallery. Then just right-click on the test in the Test Explorer and hit Debug. 回答2: Another good option is to just type System.Diagnostics.Debugger.Launch() in the test you want to debug. You'll get a Visual Studio prompt to debug the test. I would also recommend

stubbing ES6 super methods using sinon

大城市里の小女人 提交于 2019-12-21 13:58:18
问题 I am having a problem stubbing the base class methods using Sinon. In the example below I am stubbing the call to base class method GetMyDetails as follows. I am sure there is a better way. actor = sinon.stub(student.__proto__.__proto__,"GetMyDetails"); And also the value of this.Role ends up being undefined. I have created a simple class in javascript "use strict"; class Actor { constructor(userName, role) { this.UserName = userName; this.Role = role; } GetMyDetails(query,projection,populate

State/Interaction testing and confusion on mixing (or abusing) them

别来无恙 提交于 2019-12-21 12:34:10
问题 I think understand the definition of State / Interaction based testing (read the Fowler thing, etc). I found that I started state based but have been doing more interaction based and I'm getting a bit confused on how to test certain things. I have a controller in MVC and an action calls a service to deny a package: public ActionResult Deny(int id) { service.DenyPackage(id); return RedirectToAction("List"); } This seems clear to me. Provide a mock service, verify it was called correctly, done.

How should methods updating database tables be unit tested?

牧云@^-^@ 提交于 2019-12-21 12:11:18
问题 I have an application that is database intensive. Most of the applications methods are updating data in a database. Some calls are wrappers to stored procedures while others perform database updates in-code using 3rd party APIs. What should I be testing in my unit tests? Should I... Test that each method completes without throwing an exception -or- Validate the data in the database after each test to make sure the state of data is as expected My initial thought is #2 but my concern is that I

How do I do TDD efficiently with NHibernate?

泄露秘密 提交于 2019-12-21 09:37:09
问题 It seems to me that most people write their tests against in-memory, in-process databases like SQLite when working with NHibernate. I have this up and running but my first test (that uses NHibernate) always takes between 3-4 seconds to execute. The next test runs much faster. I am using FluentNhibernate to do the mapping but get roughly the same timings with XML mapping files. For me the 3-4 second delay seriously disrupts my flow. What is the recomended way of working with TDD and NHibernate

Cobra + Viper Golang How to test subcommands?

二次信任 提交于 2019-12-21 07:58:06
问题 I am developing an web app with Go. So far so good, but now I am integrating Wercker as a CI tool and started caring about testing. But my app relies heavily on Cobra/Viper configuration/flags/environment_variables scheme, and I do not know how to properly init Viper values before running my test suite. Any help would be much appreciated. 回答1: When I use Cobra/Viper or any other combination of CLI helpers, my way of doing this is to have the CLI tool run a function whose sole purpose will be