tdd

TDD. When you can move on?

夙愿已清 提交于 2019-12-01 03:17:52
When doing TDD , how to tell "that's enough tests for this class / feature"? I.e. when could you tell that you completed testing all edge cases? With Test Driven Development, you’ll write a test before you write the code it tests. Once you’re written the code and the test passes, then it’s time to write another test. If you follow TDD correctly, you’ve written enough tests once you’re code does all that is required. As for edge cases, let's take an example such as validating a parameter in a method. Before you add the parameter to you code, you create tests which verify the code will handle

Exit Protractor e2e test on fail?

冷暖自知 提交于 2019-12-01 03:11:48
问题 Does anyone out there know if there is a config that can be added to protractor's e2e.conf.js so it exits the test once it fails? Default behaviour is that if a test fails early on, you need to wait until it finishes to fix the error. From a workflow perspective, this is very frustrating. Any solutions to this problem? Thanks 回答1: no this option is missing. you could implement jasmine-bail-fast 来源: https://stackoverflow.com/questions/25496290/exit-protractor-e2e-test-on-fail

Chai assertion testing whether object structure contains at least other object structure

寵の児 提交于 2019-12-01 02:54:22
问题 I'm using Mocha for unit testing and Chai for assertions. I'd like to find an easy to use solution to check if an object has the structure and properties as defined in my comparison object. But I don't need the objects to be completely equal. The subject under test should contain at least all the properties in my test object, but it might also contain other properties which are not under test at that moment. So, I want to test a unit to check if the object it returns has at least a property

Capybara + RSpec only sees blank pages in controller specs. Why?

*爱你&永不变心* 提交于 2019-12-01 02:52:55
问题 I'm trying to write a controller spec for a simple controller. However, Capybara isn't seeing any page content. However, looking at the site's pages in my browser works just fine. What am I doing wrong? T. Hanks! My controller spec My spec_helper.rb My Gemfile 回答1: You need to explicitly tell your controller spec that you want it to render views in order for this to work. Update your spec to look like this: require 'spec_helper' describe PostsController do render_views # Render this

Mocking file objects or iterables in python

醉酒当歌 提交于 2019-12-01 02:47:49
Which way is proper for mocking and testing code that iters object returned by open() , using mock library? whitelist_data.py : WHITELIST_FILE = "testdata.txt" format_str = lambda s: s.rstrip().lstrip('www.') whitelist = None with open(WHITELIST_FILE) as whitelist_data: whitelist = set(format_str(line) for line in whitelist_data) if not whitelist: raise RuntimeError("Can't read data from %s file" % WHITELIST_FILE) def is_whitelisted(substr): return 1 if format_str(substr) in whitelist else 0 Here's how I try to test it. import unittest import mock TEST_DATA = """ domain1.com domain2.com

SEH exception with code 0xc0000005 thrown in the test body

纵饮孤独 提交于 2019-12-01 02:42:52
I am writing a test using GoogleTest for the following class and I am getting the above error. class Base { // Other Functions; CSig objSig[50]; } The Class CSig is as follows: class CSig { //... constructor, destructor(empty) and some functions CMod *objMod; CDemod *objDemod; } CSig :: CSig { bIsInitialised = false; for (int i=0; i<MAX_NUM; i++) { PStrokePrev[i] = 0.0; } } However, when I discard CSig objSig[50] , the tests run fine. What can I do to solve this issue? Also, I need to have CSig objSig[50] in the Base class. A SEH (Structured Exception Handling) exception is not a C++-exception

What do I use instead of Whitebox in Mockito 2.2 to set fields?

六眼飞鱼酱① 提交于 2019-12-01 02:22:28
When using Mockito 1.9.x I have been using Whitebox to set values of fields to "inject" mocks. Se example below: @Before public void setUp() { eventHandler = new ProcessEventHandler(); securityService = new SecurityServiceMock(); registrationService = mock(RegistrationService.class); Whitebox.setInternalState(eventHandler, "registrationService", registrationService); Whitebox.setInternalState(eventHandler, "securityService", securityService); } I really like this approach, but now that I tried to upgrade to Mockito 2.2.7 I noticed (or rather, my IDE noticed and told me quite a few times) that

Testing React: Target Container is not a DOM element

岁酱吖の 提交于 2019-12-01 02:18:56
I'm attempting to test a React component with Jest/Enzyme while using Webpack. I have a very simple test @ import React from 'react'; import { shallow } from 'enzyme'; import App from './App'; it('App', () => { const app = shallow(<App />); expect(1).toEqual(1); }); The relative component it's picking up is : import React, { Component } from 'react'; import { render } from 'react-dom'; // import './styles/normalize.css'; class App extends Component { render() { return ( <div>app</div> ); } } render(<App />, document.getElementById('app')); However, running jest causes a failure: Invariant

Windows Phone 7 mocking framework?

柔情痞子 提交于 2019-12-01 01:31:23
问题 Are there any mocking frameworks for Windows Phone 7 or do I need to create fakes manually? I've not found any on google, and although I found Moq listed on WP7 resources page, I couldn't get it working. 回答1: There are no Mocking frameworks that support WP7 and I suspect there will never be any until WP7 supports Reflection.Emit. On the .net framework there are many options that exist for the creation of a mocking framework (Profiler API, CodeDem, Refleciton.Emit, et al). The majority of

How to define a simple global variable in an rspec test that can be accesed by helper functions

回眸只為那壹抹淺笑 提交于 2019-12-01 00:53:23
问题 I cant figure out how to use a simple global variable in an rspec test. It seems like such a trivial feature but after much goggleing I havent been able to find a solution. I want a variable that can be accessed/changed throughout the main spec file and from functions in helper spec files. Here is what I have so far: require_relative 'spec_helper.rb' require_relative 'helpers.rb' let(:concept0) { '' } describe 'ICE Testing' do describe 'step1' do it "Populates suggestions correctly" do