tdd

How can I make jasmine.js stop after a test failure?

老子叫甜甜 提交于 2019-12-05 02:12:50
I want the runner to stop after the first failure rather than running all the tests. It's a hack, but you can do this by inserting this script before your first test; <script type="text/javascript"> // after every test has run afterEach(function () { // check if any have failed if(this.results_.failedCount > 0) { // if so, change the function which should move to the next test jasmine.Queue.prototype.next_ = function () { // to instead skip to the end this.onComplete(); } } }); </script> Jasmine's latest commit at the time of applying this was https://github.com/pivotal/jasmine/commit

Testing the User.IsInRole in MVC.NET

耗尽温柔 提交于 2019-12-05 02:09:24
问题 I am trying to test the User.IsInRole("Administrator") in my application, and actually trying to assign the User Role to ("Administrator") so that my test will pass. I am using Scott Hanselman's MvcMockHelpers to do this, and at the moment I have the following test. [Test] public void Create_CanInsertNewArticleView_IsNotNull() { // Arrange var controller = new ArticleController(); MockRepository mockRepo = new MockRepository(); var fakeContext = MvcMockHelpers.FakeHttpContext(mockRepo, "~

When is it preferable to store data members as references instead of pointers?

我的梦境 提交于 2019-12-05 01:38:00
Let's say I have an object Employee_Storage that contains a database connection data member. Should this data member be stored as a pointer or as a reference? If I store it as a reference, I don't have to do any NULL checking. (Just how important is NULL checking anyway?) If I store it as a pointer, it's easier to setup Employee_Storage (or MockEmployee_Storage ) for the purposes of testing. Generally, I've been in the habit of always storing my data members as references. However, this makes my mock objects difficult to set up, because instead of being able to pass in NULL s (presumably

DUnit: How to run tests?

会有一股神秘感。 提交于 2019-12-05 01:34:55
How do i run TestCase 's from the IDE? i created a new project, with a single, simple, form: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) private public end; var Form1: TForm1; implementation {$R *.DFM} end. Now i'll add a test case to check that pushing Button1 does what it should: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private public end; var

How Do You Keep Automated Tests in Synch With Test Plans

帅比萌擦擦* 提交于 2019-12-05 01:18:39
问题 Everyone can agree that it's helpful to have many automated tests (system tests and unit tests) and to have written test plans. But how do you keep those tests synchronized with your Test Case Management tool or with your written test plans? In particular, how do you avoid the awkwardness of needing to update tests in both places? 回答1: I'm not aware of any silver bullet solution for this. To my knowledge there is no round-trip testing system. I think it will be necessary to update your test

Testing Frameworks for C [closed]

做~自己de王妃 提交于 2019-12-05 01:15:58
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . After doing some work with Ruby, Rails, and RSpec last summer and I learned to TATFT. Now I can't write code without writing tests

Mocking with Boost::Test

被刻印的时光 ゝ 提交于 2019-12-05 00:53:42
I'm using the Boost::Test library for unit testing, and I've in general been hacking up my own mocking solutions that look something like this: //In header for clients struct RealFindFirstFile { static HANDLE FindFirst(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) { return FindFirstFile(lpFileName, lpFindFileData); }; }; template <typename FirstFile_T = RealFindFirstFile> class DirectoryIterator { //.. Implementation } //In unit tests (cpp) #define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42 struct FakeFindFirstFile { static HANDLE FindFirst(LPCWSTR lpFileName, LPWIN32_FIND

Testing devise views with rspec

时光怂恿深爱的人放手 提交于 2019-12-05 00:28:52
I have generated Devise's views running rails g devise:views and would now like to test them. This is what I have come up with: require 'spec_helper' describe "devise/sessions/new" do before do render end it "renders the form to log in" do rendered.should have_selector("form", action: user_session_path, method: :post) do |form| end end end For the render statement it gives me undefined local variable or method 'resource' . After googling around I found that I should add @user.should_receive(:resource).and_return(User.new) before the render statement - but it still gives me the same error, and

SenTestingKit (integrated with XCode) versus GHUnit on XCode 4 for Unit Testing?

我怕爱的太早我们不能终老 提交于 2019-12-05 00:19:12
问题 Any advice on which way to go regarding Unit Testing on XCode 4 out of SenTestingKit (the inbuild unit testing framework with XCode 4) and GHUnit? In particular: With the apparent improvements to Unit Testing in XCode 4 does this mean there are no major benefits of running with GHUnit? Alternatively are there some integration benefits that make a smooth development process that could be achieved using XCode's unit testing framework (SenTestingKit) as opposed to GHUnit? 回答1: Greg, I answered

Eclipse: bind some key for all unit tests

拈花ヽ惹草 提交于 2019-12-04 23:58:04
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. You need to change eclipse's run mode. By default, it will try to run whatever is selected or being edited. You want to it always run the "last thing executed". Go to Window->Preferences->Run/Debug->Launching Choose "Always