testing

How to write registering account test cases?

两盒软妹~` 提交于 2020-01-03 00:54:24
问题 This is a follow up question on this post After tweak my code as suggestion on the original post, below is my full working code. However, I have some problems and questions: How to test createAccount () that can create account successfully or can throw exception ? This is my test but createAccount() doesn't have parameters, so how to add input to it for testing ? def test_canCreateAccount(ctrl): #valid email and password email = 'hello@gmail.com' password1 = 'beautiful' password2 = 'beautiful

Mocha async test handle errors

断了今生、忘了曾经 提交于 2020-01-02 19:34:22
问题 I'm trying to create a test case with Mocha but my code is asynchronous. That's fine, I can add a "done" callback function to "it" and that will work perfectly fine for positive cases. But when trying to test negative cases, it will just make the test fail. I would like to make something like this but asynchronous: someObject.someMethod(null).should.equal(false) Instead I can only test for a callback to return, instead of testing what really happend (null is not valid): it('this should return

Mocha async test handle errors

≡放荡痞女 提交于 2020-01-02 19:34:08
问题 I'm trying to create a test case with Mocha but my code is asynchronous. That's fine, I can add a "done" callback function to "it" and that will work perfectly fine for positive cases. But when trying to test negative cases, it will just make the test fail. I would like to make something like this but asynchronous: someObject.someMethod(null).should.equal(false) Instead I can only test for a callback to return, instead of testing what really happend (null is not valid): it('this should return

Rails testing error: argument of WHERE must be type boolean, not type integer

杀马特。学长 韩版系。学妹 提交于 2020-01-02 16:24:23
问题 Users can vote for Posts through a has_many association. I'm getting this error from running tests: ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer From this test: test "should unvote a post the standard way" do @user.vote(@post_2) postvoterelationship = @user.active_post_vote_relationships.find_by(voted_id: @post_2.id) assert_difference '@user.postvoting.count', -1 do delete postvoterelationship_path(postvoterelationship)

Unit testing on “react + react-route” stack

蓝咒 提交于 2020-01-02 16:15:23
问题 I've read many recommendations of how it's possible to render routed via react-router components, but I still can't to make it work. I tried to find it using github codebase search, still no luck. And at this point all I need is one working example. Here is my boilerplate project, but maybe it's not important. I just want to see some react-route unit-testing working example. 回答1: I got mine working after I found the super-secret hidden react-router testing guide. Instead of using Object

Unit testing on “react + react-route” stack

吃可爱长大的小学妹 提交于 2020-01-02 16:15:07
问题 I've read many recommendations of how it's possible to render routed via react-router components, but I still can't to make it work. I tried to find it using github codebase search, still no luck. And at this point all I need is one working example. Here is my boilerplate project, but maybe it's not important. I just want to see some react-route unit-testing working example. 回答1: I got mine working after I found the super-secret hidden react-router testing guide. Instead of using Object

Testing with Twisted and inlineCallbacks

亡梦爱人 提交于 2020-01-02 15:02:12
问题 Here is my function definition: @defer.inlineCallbacks def get_order(order_id): # do some db operations... defer.returnValue(order_details) What I want to do is to test this function using Twisted's trial: from twisted.trial import unittest from twisted.internet import defer class OrderTest(unittest.TestCase): @defer.inlineCallbacks def test_order(self): order = yield get_order(5) raise Exception('FAIL FAIL!!') # this should fail, but never does self.assertEqual(order.id, 6) I'm very confused

Unit Testing validates presence of odd behaviour

ぐ巨炮叔叔 提交于 2020-01-02 14:06:10
问题 I'm trying out the whole TDD and I'm running into a problems with validate presence. I have a model called Event and I want to ensure that when an Event is created that a title a price and a summary exists. Unit Test Code class EventTest < ActiveSupport::TestCase test "should not save without a Title" do event = Event.new event.title = nil assert !event.save, "Save the Event without title" end test "should not save without a Price" do event = Event.new event.price = nil assert !event.save,

Multivariate Testing for Sublayouts in Sitecore

人盡茶涼 提交于 2020-01-02 09:31:48
问题 Having toyed with the concept in the past, I am interested in using multivariate testing on my companies Sitecore website. There are a number of places where I feel we can definitely improve sales through the use of A/B testing in: Running two entirely different templates to see what layouts work better for users Running a number of different Sublayouts (forms) on the site to see which ones people are more likely to fill out Trialling different content - Running two different sets of copy to

How to make two posts with different contents in GrailsIntegrationTesting

戏子无情 提交于 2020-01-02 09:28:34
问题 I'm testing a controller, and I cannot make two posts with different contents. Follows an example, in which I execute a post to the cardController, with some data (post1, with json1). Then, I execute another post, with different data (post2 with json2). But I cannot make the second post succesfully, because I've seen (debuggin the application), that the json in the request, is json1 again, and not josn2. So, how can I make two different posts in the same test? void testSomething(){ def json1