tdd

Calling trigger() doesn't always fire when called from QUnit

橙三吉。 提交于 2019-12-11 02:38:16
问题 Although I've used QUnit in the past, it's been a year since I really used it, so I am hoping this is something trivial! I have a bunch of QUnit tests that are working really well, apart from one that fails every other time that the page is loaded. If I refresh, the test works, but if I refresh again it breaks! It's become predictable but I cannot see why it's not working. The test in question should use a trigger('change') event, but this only fires every other time. I have a dynamically

Spork, Vagrant, and Rspec

回眸只為那壹抹淺笑 提交于 2019-12-11 02:37:40
问题 So, I'm working in a pretty complex development enviornment that is hard to replicate locally on my Mac, so we're using Vagrant boxes and Chef scripts to keep everyone on the same page. What I would like to do, is be able to run my RSpec tests locally (on the Mac), but have them connect to the DRb server (spork) running on the Vagrant box. In my Vagrantfile, I've done the following to forward the Spork port to the Mac host: config.vm.forward_port 8989, 8989 . I ssh into the Vagrant box, and

Can't figure out what's causing my tests to fail

99封情书 提交于 2019-12-11 01:12:24
问题 I'm new to rails and I built an app without doing TDD but am now going back and trying to pass all the tests. I've passed most of them but there are a few left relating to the same issue that I can't figure out. The app functions correctly as well, I just can't pass these tests. The tests fail and provide this: 1) ProductsController POST create with valid params assigns a newly created product as @product Failure/Error: post :create, {:product => valid_attributes}, valid_session Paperclip:

How to Mock a user input in Python

落花浮王杯 提交于 2019-12-11 01:07:36
问题 I am currently trying to learn how to Unit Test with Python and was introduced to the concept of Mocking, I am a beginner Python developer hoping to learn the concepts of TDD alongside my development of Python skills. I am struggling to learn the concept of mocking a class with a given input from the user for Python unittest.mock documentation. If I could get an example of how I would mock a certain function, I would be really grateful. I will use the example found here: Example Question

Unit Testing(Mocking) Databases, How To Verify Database Methods With Mocking?

我是研究僧i 提交于 2019-12-11 00:54:05
问题 As a person has no experience before in unit testing and mocking, I followed beginner tutorials about JUnit with Mockito and I do some practice. Now, I need to unit test some class methods which do basic database operations on a MySQL database. I don't want to make real changes on the database. In my code: @InjectMocks private DBConnection dbConnection; @Mock private DBConnection mockDBConnection; @Test public void testDropTable() { Mockito.when(mockDBConnection.dropTable()).thenReturn(0); //

BDD or TDD? Which do you prefer? and why? [closed]

故事扮演 提交于 2019-12-10 23:33:13
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I see many developers disagree on which style of test to use while starting a new project. I'd like to know why you choose this particular style over the other. 回答1: TDD v BDD is really a state of mind. The way I see it is, in TDD a lot of emphasis is on what should this

IntelliJ IDEA - Navigate to test subject

隐身守侯 提交于 2019-12-10 22:49:06
问题 I'm trying to apply TDD principles when working in the IntelliJ IDEA but I'm encountering a problem and I don't know if there is a feature or a plugin I don't know about to help me. I've just discovered that you can easily Navigate to the test class corresponding to current class in the editor with CTRL + SHIFT + T . If the Test Class does not exist, it will ask you to create it. In a reverse situation, when I create a Test Class with no corresponding Test Subject and that I press the

Refactoring phase of the TDD Traffic Light - how to get this right?

爱⌒轻易说出口 提交于 2019-12-10 22:13:16
问题 So I made the following test for a class Board that would to be born: [TestMethod] public void Set_The_Origin_As_Violet_And_The_Query_Confirms_It() { Board board = new Board(10, 10); Color expected = Color.Violet; board.SetColorAt(0, 0, expected); Color actual = board.GetColorAt(0, 0); Assert.AreEqual(expected, actual); } I tried running the code, but the compiler signaled that Board didn't exist. So I created it. I tried to run the code again, but it was of no avail, as both SetColorAt() and

Code Coverage in Intellij 10 CE

坚强是说给别人听的谎言 提交于 2019-12-10 21:24:47
问题 Is there a community plugin or EMMA tool for Code Coverage in Intellij 10 CE? I know it's available as part of the paid version, but the bigwigs won't spring for it. Any alternatives? 回答1: No, that's in the enterprise edition. (Works great for both Java and web projects.) I ante up for a personal license every year. It's not too much money, and it's worth having. If the bigwigs won't spring for it, put your money where your mouth is and buy it yourself. 来源: https://stackoverflow.com/questions

Does one still write tests with TDD when the desired code has little to no logic? Why?

左心房为你撑大大i 提交于 2019-12-10 20:14:09
问题 TDD is supposed to have 100% code coverage. Does this mean one is supposed to write tests for property getter and setters, and other methods that contain no real logic, such as dealing with external API functionality? Example 1: Below is one example method (which happens to also be the example in this other SO question which deals with how best to test it, if we are going to test it). This method doesn't do much. It's a facade of the System.ServiceProcess.ServiceController functionality of