tdd

Moq testing LINQ Where queries

送分小仙女□ 提交于 2019-12-21 07:06:36
问题 I'm using EF 4.1 to build a domain model. I have a Task class with a Validate(string userCode) method and in it I want to ensure the user code maps to a valid user in the database, so: public static bool Validate(string userCode) { IDbSet<User> users = db.Set<User>(); var results = from u in users where u.UserCode.Equals(userCode) select u; return results.FirstOrDefault() != null; } I can use Moq to mock IDbSet no problem. But ran into trouble with the Where call: User user = new User {

Rails: Unit testing a before_create?

…衆ロ難τιáo~ 提交于 2019-12-21 05:51:10
问题 I am trying to test that a field is being generated properly by a callback, but I can't figure this one out. album.rb before_create :generate_permalink private def generate_permalink @title = album.downcase.gsub(/\W/, '_') @artist = artist.downcase.gsub(/\W/, '_') self.permalink = @artist + "-" + @title end album_test.rb test "should return a proper permalink" do album = Album.new(:artist=>'Dead Weathers', :album=>'Primary Colours') album.save assert_equal "dead_weathers-primary_colours",

Difference between Unit::Test versus Rspec [closed]

牧云@^-^@ 提交于 2019-12-21 05:51:09
问题 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 4 years ago . I am interested in Test::Unit and Rspec . Could someone explain me what is the main difference between the two - in terms of principles on which they operate. 回答1: Test::Unit is more akin to a classic TDD tool like JUnit. Tests are written as classes (because that's how it

Rails: Unit testing a before_create?

本小妞迷上赌 提交于 2019-12-21 05:51:05
问题 I am trying to test that a field is being generated properly by a callback, but I can't figure this one out. album.rb before_create :generate_permalink private def generate_permalink @title = album.downcase.gsub(/\W/, '_') @artist = artist.downcase.gsub(/\W/, '_') self.permalink = @artist + "-" + @title end album_test.rb test "should return a proper permalink" do album = Album.new(:artist=>'Dead Weathers', :album=>'Primary Colours') album.save assert_equal "dead_weathers-primary_colours",

What's the point of testing fake repositories?

柔情痞子 提交于 2019-12-21 04:22:19
问题 I've been trying to push my mentallity when developing at home to be geared more towards TDD and a bit DDD. One thing I don't understand though is why you would create a fake repository to test against? I haven't really looked into it much but surely the idea of testing is to help decouple your code (giving you more flexability), trim down code needed and bring down the number of bugs. So can someone fill in my foolish brain as to why some like to test fake repositories? I would have thought

TDD: Why is there only one test per function?

僤鯓⒐⒋嵵緔 提交于 2019-12-21 04:04:09
问题 I'm having a hard time understanding why there is only one test per function in most professional TDD code that I have seen. When I approached TDD initially I tended to group 4-5 tests per function if they were related but I see that doesn't seem to be the standard. I know that it is more descriptive to have just one test per function because you can more easily narrow down what the problem is, but I find myself struggling to come up with function names to differentiate the different tests

RhinoMocks: Correct way to mock property getter

浪子不回头ぞ 提交于 2019-12-21 03:42:47
问题 I'm new to RhinoMocks, and trying to get a grasp on the syntax in addition to what is happening under the hood. I have a user object, we'll call it User, which has a property called IsAdministrator. The value for IsAdministrator is evaluated via another class that checks the User's security permissions, and returns either true or false based on those permissions. I'm trying to mock this User class, and fake the return value for IsAdministrator in order to isolate some Unit Tests. This is what

Python unittesting: run tests in another module

独自空忆成欢 提交于 2019-12-21 03:38:21
问题 I want to have the files of my application under the folder /Files, whereas the test units in /UnitTests, so that I have clearly separated app and test. To be able to use the same module routes as the mainApp.py, I have created a testController.py in the root folder. mainApp.py testController.py Files |__init__.py |Controllers | blabla.py | ... UnitTests |__init__.py |test_something.py So if in test_something.py I want to test one function that is in /Files/Controllers/blabla.py, I try the

Googletest for Android NDK

六月ゝ 毕业季﹏ 提交于 2019-12-21 03:18:13
问题 I checked a previous answer about unit test for Android, where it is suggested Googletest as a good option. However, I got a look into the Google C++ Testing Framework - Googletest. About platforms, I don't see anything mentioning support to Android. Could someone tell anything, if there is some way of using it with Android devices - e.g. steps to build a toolchain, etc? 回答1: You need to built Googletest for Android to be able to run it with your toolchain, as you working with cross

How do I tell MSTEST to run all test projects in a Solution?

老子叫甜甜 提交于 2019-12-21 03:17:22
问题 I need to know how to tell MSTEST to run all test projects in a solution file. This needs to be done from the command line. Right now I have to pass it a specific project file, I'm trying to get it to run from a SOLUTION file. I'm hoping this is possible, because in Visual Studio, hitting Ctrl+R, A, runs ALL tests in the currently opened solution. The way I've interpretted the help files, you have to pass in each DLL specifically. I want to run this from the command line from my CruiseControl