tdd

How do I unit test persistence?

回眸只為那壹抹淺笑 提交于 2020-01-20 13:31:48
问题 As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database. I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following: Testing queries. Testing inserts. How do I know that the insert that has gone wrong if it fails? I can test it by inserting and then querying, but how can I know that the query wasn't wrong? Testing updates and deletes -- same

How do I unit test persistence?

夙愿已清 提交于 2020-01-20 13:31:27
问题 As a novice in practicing test-driven development, I often end up in a quandary as to how to unit test persistence to a database. I know that technically this would be an integration test (not a unit test), but I want to find out the best strategies for the following: Testing queries. Testing inserts. How do I know that the insert that has gone wrong if it fails? I can test it by inserting and then querying, but how can I know that the query wasn't wrong? Testing updates and deletes -- same

How to resolve Dependency within Dependency

…衆ロ難τιáo~ 提交于 2020-01-17 04:11:10
问题 I have 4 Projects in a solution DAL_Project BLL_Project Interface_Project WebApi_Project Interface_Project has two interfaces ICar_DAL and ICar_BLL DAL_Project has a class Car_DAL that implements ICar_DAL BLL_Project has a class Car_BLL that implements ICar_BLL and its constructor takes in ICar_DAL WebApi_Project has an api controller CarApiController and its constructor takes in ICar_BLL the dependency resolution of WebApi Controller's constructor is done by Unity.WebApi using this in

Jest not auto mocking common js modules

假装没事ソ 提交于 2020-01-15 08:28:48
问题 I am trying to wrap my head around testing Flux and React applications using Jest. I started using Scotch.io tutorial as my starting point and will be creating a full test suite to gain knowledge in how to structure my first real react and flux app. You can find my code on github to see where I am at. The test that does not run is FluxProduct-test.jsx jest.dontMock('../FluxProduct'); var React , TestUtils , FluxProduct , FluxCartActions; describe('FluxProduct', function() { var SAMPLE = {

Jest not auto mocking common js modules

橙三吉。 提交于 2020-01-15 08:24:29
问题 I am trying to wrap my head around testing Flux and React applications using Jest. I started using Scotch.io tutorial as my starting point and will be creating a full test suite to gain knowledge in how to structure my first real react and flux app. You can find my code on github to see where I am at. The test that does not run is FluxProduct-test.jsx jest.dontMock('../FluxProduct'); var React , TestUtils , FluxProduct , FluxCartActions; describe('FluxProduct', function() { var SAMPLE = {

How can I determine the subject of an rspec controller test?

房东的猫 提交于 2020-01-15 04:51:11
问题 So I don't have a great reason for needing to know this other than curiosity - the BEST reason - but I'm not sure what's going on here. Background: I'm working through the RSpec book and updating the examples. On Chapter 24 - Rails Controllers there's a test for a messages controller. ## spec/controllers/messages_controller_spec.rb ## require 'spec_helper' describe MessagesController do describe "POST create" do let(:message) { mock_model(Message).as_null_object } before do Message.stub(:new)

How to assert that a method call was not made, without any_instance?

ε祈祈猫儿з 提交于 2020-01-15 01:22:25
问题 I have a class, that in one situation should call :my_method , but in another situation must not call method :my_method . I would like to test both cases. Also, I would like the test to document the cases when :my_method should not be called. Using any_instance is generally discouraged, so I would be happy to learn a nice way to replace it. This code snippet is a reduced example on what I kind of test I would like to write. class TestSubject def call call_me end def call_me; end def never

How to use Cucumber to test non-Ruby, non-Rack API's

不羁的心 提交于 2020-01-13 19:00:28
问题 I use cucumber for lots of things. I really like it as a BDD environment. So I'd like to use it as an external tool to test an API. I'd like to do things like: Scenario: Hit api /info path and get info back When I visit the API path '/info' Then I should see the following text "Here's info on the API" or something similar. I mainly want to treat the API as a black box and test only inputs and outputs. I don't plan on inspecting anything inside the API. Most of the libraries I've looked at

Unit Testing Dababase Applications

好久不见. 提交于 2020-01-13 09:43:32
问题 I am trying to get in to the TDD realm, and I'm having a hard time unit testing a few user models I have. I'm trying to test the validation of my models, and the business requirements are as follows: >= 6 character username required >= 5 character password, with at least 1 letter and number valid email format required ... blah blah blah username and email cannot already exist in the DB All requirements are easily testable, except 5, which requires the database to be in a known state. I know

Unit Testing Dababase Applications

柔情痞子 提交于 2020-01-13 09:41:50
问题 I am trying to get in to the TDD realm, and I'm having a hard time unit testing a few user models I have. I'm trying to test the validation of my models, and the business requirements are as follows: >= 6 character username required >= 5 character password, with at least 1 letter and number valid email format required ... blah blah blah username and email cannot already exist in the DB All requirements are easily testable, except 5, which requires the database to be in a known state. I know