tdd

NUnit 2.6.2 TestContext.CurrentContext always null

喜你入骨 提交于 2019-12-11 11:47:58
问题 I'm trying to use the TestContext.CurrentContext of NUnit 2.6.2 but it's always null. What I would like is to have an output with the result of tests, but if I run the following code I always get a NullReferenceException in the TearDown method. All the properties inside Test and Result are throwing the exception. [TestFixture] public class UtilitiesTests { [TearDown] public void TearDown() { //using console here just for sake of simplicity. Console.WriteLine(String.Format("{0}: {1}",

Why is Jasmine not executing it() on this async test?

好久不见. 提交于 2019-12-11 10:58:15
问题 I'm trying to test a prototypal method that returns insights about a dataset I am loading via AJAX. $.getJSON('../data/bryce.json').done(function(data) { insights = new Insights(data); describe("People Method", function() { console.log('it executes this far'); it("should return complete people data", function() { console.log('but not this far'); expect(insights.people()).toBeTruthy(); }); }); }); When I run this test suite, describe() executes, but not it(). I'm pretty new to JavaScript

How can I overriding class with proc and yield in test on rails?

空扰寡人 提交于 2019-12-11 10:15:26
问题 I have below classes(only for example), class Background def self.add_thread(&blcok) Thread.new do yield ActiveRecord::Base.connection.close end end end class Email def send_email_in_other_thread Background.add_thread do send_email end end def send_email UserMailer.greeting_email.deliver_now end end And below codes are for tests, class EmailTest < ActiveSupport::TestCase class Background def self.add_thread(&block) yield end end test 'should send email' do assert_difference 'ActionMailer:

Mocking free function

吃可爱长大的小学妹 提交于 2019-12-11 09:33:01
问题 I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it is accessed like this: foo()->bar() . I cannot find a way to mock this behavior. And I cannot change the sources, so the solution in google mock cook book is out of question. Any help or pointers in the right direction will be highly appreciated.

Rspec view test does not render changes

空扰寡人 提交于 2019-12-11 09:03:31
问题 I am testing a view in my rails 3.2 application with rspec. I have wrote tests for my view to include some additional input fields, and they correctly failed. However, after adding the desired input fields, the tests still fail the same way. They output the form in the terminal, and it is as if I hadn't changed anything in the views. When inspecting the view in the browser, the fields are in fact there, so the tests should pass. Has rspec not loaded the latest views? Here is some code (I have

Multiple tests with minitest

只谈情不闲聊 提交于 2019-12-11 08:46:06
问题 I have an app with some specs written into minitest. As usual, I start them using rake . Because some times I got a random results, my specs can pass one time, and fail an other time. In this case, I can keep the sequence number and replay it later, after fixing. Because I have this kind of tests (with a random result), I generally run rake many time, just to be sure that the app is okay. I would like to know if there is a nice way to perform multiple rake tests (100 times for example), and

Mock() function gives TypeError in django2

假如想象 提交于 2019-12-11 08:14:10
问题 I'm following this tutorial. When I run test_views.py I have an error that shouldn't be there according the author: TypeError: quote_from_bytes() expected bytes . My views and my test_views are the same like the book, but I'm using django 2.0.6 instead django 1.11 so my url.py change, so maybe here's the problem. Edit: at a second look the problem appears to be in the mock() function. When I use patch('lists.views.List') the Print(list_) in my view gives <MagicMock name='List()' id='79765800'

NUnit, Neither Assert.Throws nor [ExpectedException] Catch Thrown Exception

橙三吉。 提交于 2019-12-11 07:35:10
问题 Before I start, I want to make it clear that I've already checked for solutions in both this question and this question. The Method to Test public static DataSet ExecuteDataSet(this SqlConnection connection, string sql) { if (null == connection || null == sql) { throw new ArgumentNullException(); } using (var command = connection.CreateCommand()) { // Code elided for brevity } } The Test Methods [Test] [ExpectedException(typeof(ArgumentNullException))] public void

Clojure test with multiple assertions

孤街浪徒 提交于 2019-12-11 06:59:46
问题 I am starting to learn how to write tests for my Clojure program. I have a test with multiple assertions (calls to is ). I want the test to stop running as soon as the first assertion fails. Here is my test: (deftest register-one-command (testing "Register-one-command" (do (is (= 0 (count @test/list-of-commands))) (test/add-to-list-of-commands ["A"]) (is (= 1 (count @test/list-of-commands)))))) If the first is fails, I want the whole thing to fail. 回答1: The simplest way is to just wrap the

TDD: Number of Asserts, and what to actually assert? [closed]

旧城冷巷雨未停 提交于 2019-12-11 06:09:36
问题 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 6 years ago . I am currently writing tests using TDD and I have come up against a few queries. Normally when writing unit tests, i always used to use 1 assert per unit tests as this is what is defined as good practice and its easy to see why your test is failing. In TDD, is it also good