Search Results

Search found 299 results on 12 pages for 'rhino mocks 3 5'.

Page 9/12 | < Previous Page | 5 6 7 8 9 10 11 12  | Next Page >

  • C++ Mock/Test boost::asio::io_stream - based Asynch Handler

    - by rbellamy
    I've recently returned to C/C++ after years of C#. During those years I've found the value of Mocking and Unit testing. Finding resources for Mocks and Units tests in C# is trivial. WRT Mocking, not so much with C++. I would like some guidance on what others do to mock and test Asynch io_service handlers with boost. For instance, in C# I would use a MemoryStream to mock an IO.Stream, and am assuming this is the path I should take here. C++ Mock/Test best practices boost::asio::io_service Mock/Test best practices C++ Async Handler Mock/Test best practices I've started the process with googlemock and googletest.

    Read the article

  • How can I expose a service bus by a wcf service to be consumed by a silverlight client

    - by illdev
    In a Silverlight application, instead of consuming and writing (wcf) wrappers around messages that finally get sent to the bus, I want to send use my message bus as directly as possible. My idea was to expose the service bus directly as a wcf service, or, in other terms, I want to bidirectionally pub/sub over the wire. Has this been done already? Is bi-directionality doable at all? After all, we are (are we restricted to that?) in the http domain? Lots of questions. Some head start would be greatly appreciated! I am in .NET land, with using Rhino Service Bus, but the pattern should apply to different platforms.

    Read the article

  • Scripting language to embed into a Java server application

    - by Alexey Kalmykov
    I want to make a business logic of server side Java application as a set of scripts. So I need from a scripting engine: Maximum Java interoperability (i.e. Spring framework) Script reloading and recompiling Easy DB access from scripting language Clear and simple syntax (some DSL capabilities would be nice to have), easy learning curve for non-hardcore developers Performance and stability I had some experience in the similar project with Rhino and it was pretty good. But I want to see if there is something better. Currently I'm looking into Groovy. JRuby and Jython are a bit more complex than I need for this task. Any other suggestion? What to take into consideration?

    Read the article

  • Where can I find a proper JavaScript beautifier

    - by Ernelli
    I have used http://jsbeautifier.org/ successfully using Rhino and ant, but the problem is that it is not deterministic. If you run the beautifier twice on a file the result is different from each time, e.g. each pass inserts additional array intendation on some lines. I have spent a lot of time debugging the code in beautify.js and have made some workarounds for comment handling, but the array indentation bug is annoying. Is there a correct and properly working JS code formatter anywhere that can be used as part of a source code indentation verification system? EDIT I have now tested with preserve-array-formating disabled, and it seems that it solves the problem. Too bad, since preserve-array-formating is quite useful with large array constructs.

    Read the article

  • Howto mix TDD and RAII

    - by f4
    I'm trying to make extensive tests for my new project but I have a problem. Basically I want to test MyClass. MyClass makes use of several other class which I don't need/want to do their job for the purpose of the test. So I created mocks (I use gtest and gmock for testing) But MyClass instantiate everything it needs in it's constructor and release it in the destructor. That's RAII I think. So I thought, I should create some kind of factory, which creates everything and gives it to MyClass's constructor. That factory could have it's fake for testing purposes. But's thats no longer RAII right? Then what's the good solution here?

    Read the article

  • A consistent and simple group of IDE and tools for embedded code and unit test in C++ ?

    - by TridenT
    I’m starting a new firmware project in C++ for Texas Instrument C283xx and C6xxx targets. The unit tests will not run on the target, but will be compiled with gcc/gcov on a PC with windows (and run as well on PC) with simple metrics for tested code coverage. The whole project will be part of Cruise Control.NET for continuous integrations. My question is: what are the consistent IDE / framework / tools to work together? A/ One of the developers says CodeComposerStudio V3.1 for application and CodeBlocks + CxxUnit for the Unit tests. B/ I’m more attracted with CodeComposerStudio V4 for application, Eclipse CDT (well, as CCS V4) and CppUnit for unit test + MockCpp for mocks. I don’t want the best in class tools for each process, but a global, consistent and easy solution (or group of tools if you prefer).

    Read the article

  • Doesn't JavaScript support closures with local variables?

    - by qollin
    I am very puzzled about this code: var closures = []; function create() { for (var i = 0; i < 5; i++) { closures[i] = function() { alert("i = " + i); }; } } function run() { for (var i = 0; i < 5; i++) { closures[i](); } } create(); run(); From my understanding it should print 0,1,2,3,4 (isn't this the concept of closures?). Instead it prints 5,5,5,5,5. I tried Rhino and Firefox. Could someone explain this behavior to me? Thx in advance.

    Read the article

  • Does isolation frameworks (Moq, RhinoMock, etc) lead to test overspecification?

    - by Marius
    In Osherove's great book "The Art of Unit Testing" one of the test anti-patterns is over-specification which is basically the same as testing the internal state of the object instead of some expected output. To my experience, using Isolation frameworks can cause the same unwanted side effects as testing internal behavior because one tends to only implement the behavior necessary to make your stub interact with the object under test. Now if your implementation changes later on (but the contract remains the same), your test will suddenly break because you are expecting some data from the stub which was not implemented. So what do you think is the best approach to counter this? 1) Implement your stubs/mocks fully, this has the negative side-effect of potentially making your test less readable and also specifying more than necessary to make your test pass. 2) Favor manual, fully implemented fakes. 3) Implement your stubs/fakes so that they make your test just pass, and then deal with the brittleness that this might introduce.

    Read the article

  • What is the best way to mock a 3rd party object in ruby?

    - by spinlock
    I'm writing a test app using the twitter gem and I'd like to write an integration test but I can't figure out how to mock the objects in the Twitter namespace. Here's the function that I want to test: def build_twitter(omniauth) Twitter.configure do |config| config.consumer_key = TWITTER_KEY config.consumer_secret = TWITTER_SECRET config.oauth_token = omniauth['credentials']['token'] config.oauth_token_secret = omniauth['credentials']['secret'] end client = Twitter::Client.new user = client.current_user self.name = user.name end and here's the rspec test that I'm trying to write: feature 'testing oauth' do before(:each) do @twitter = double("Twitter") @twitter.stub!(:configure).and_return true @client = double("Twitter::Client") @client.stub!(:current_user).and_return(@user) @user = double("Twitter::User") @user.stub!(:name).and_return("Tester") end scenario 'twitter' do visit root_path login_with_oauth page.should have_content("Pages#home") end end But, I'm getting this error: 1) testing oauth twitter Failure/Error: login_with_oauth Twitter::Error::Unauthorized: GET https://api.twitter.com/1/account/verify_credentials.json: 401: Invalid / expired Token # ./app/models/user.rb:40:in `build_twitter' # ./app/models/user.rb:16:in `build_authentication' # ./app/controllers/authentications_controller.rb:47:in `create' # ./spec/support/integration_spec_helper.rb:3:in `login_with_oauth' # ./spec/integration/twit_test.rb:16:in `block (2 levels) in <top (required)>' The mocks above are using rspec but I'm open to trying mocha too. Any help would be greatly appreciated.

    Read the article

  • Silverlight unit testing (using NUnit)

    - by 1gn1ter
    I'm using NUnit for testing back-end. Unit tests are being executed while building (I'm using TeamCity for continuous building). Now I hove to test front-end (Silverlight 4.0). Because the tests are being executed while building, I have to simulate browser (TypeMock - is not free, isn't it?) could I use NUnit.Mocks somehow?. How to use NUnit for Silverlight testing? I've found WHITE framework could it help? Any other advises about software/frameworks to use for Silverlight unit testing?

    Read the article

  • Navigation properties not set when using ADO.NET Mocking Context Generator

    - by olenak
    I am using ADO.NET Mocking Context Generator plugin for my Entity Framework model. I have not started on using mocks yet, just trying to fix generated entity and context classes to make application run as before without exceptions. I've already fixed T4 template to support SaveChanges method. Now I've got another problem: when I try to access any navigation property it is set to null. All the primitive fields inherited from DB table are set and correct. So what I am doing is the following using (var context = MyContext()) { var order = context.Orders.Where(p => p.Id == 7); var product = order.Products; } in this case product is set to null. But that was not a case while using default code generator, it used to return real product object. Thanks ahead for any suggestions!

    Read the article

  • What is the best way to automated (integration) test with java with OpenId4Java against real OpenIdP

    - by mP
    I would like to do a bit more than manually test my openid glue code which happens to use the openid4java library. My goals would be to be able to run it within my IDE with a bunch of tests using Junit or similar. Selenium & tomcat I was thinking of using selenium and a tomcat but thats not exactly a nice approach as this is a bit heavy and not really lightweight. httpunit A solution with http-unit is incomplete because it doesnt really fit with the redirect to my openid provider, authenticate and redirect back. Perhaps i am wrong but this looks like it could get quite involved just to make sure this works. Mocks My last solution is to mock everything and assume thats its accurate and works. If google or yahoo ever change in some way, then ill have to verify manually. The approach is simple but with a major flaw.

    Read the article

  • rspec mocking object property assignment

    - by charlielee
    I have a rspec mocked object, a value is assign to is property. I am struggleing to have that expectation met in my rspec test. Just wondering what the sytax is? The code: def create @new_campaign = AdCampaign.new(params[:new_campaign]) @new_campaign.creationDate = "#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}" if @new_campaign.save flash[:status] = "Success" else flash[:status] = "Failed" end end The test it "should able to create new campaign when form is submitted" do campaign_model = mock_model(AdCampaign) AdCampaign.should_receive(:new).with(params[:new_campaign]).and_return(campaign_model) campaign_model.should_receive(:creationDate).with("#{Time.now.year}/#{Time.now.mon}/#{Time.now.day}")campaign_model.should_receive(:save).and_return(true) post :create flash[:status].should == 'Success' response.should render_template('create') end The problem is I am getting this error: Spec::Mocks::MockExpectationError in 'CampaignController new campaigns should able to create new campaign when form is submitted' Mock "AdCampaign_1002" received unexpected message :creationDate= with ("2010/5/7") So how do i set a expectation for object property assignment? Thanks

    Read the article

  • How to stub Restul-authentication's current_user method?

    - by Thiago
    Hi there, I'm trying to run the following spec: describe UsersController, "GET friends" do it "should call current_user.friends" do user = mock_model(User) user.should_receive(:friends) UsersController.stub!(:current_user).and_return(user) get :friends end end My controller looks like this def friends @friends = current_user.friends respond_to do |format| format.html end end The problem is that I cannot stub the current_user method, as when I run the test, I get: Spec::Mocks::MockExpectationError in 'UsersController GET friends should call current _user.friends' Mock "User_1001" expected :friends with (any args) once, but received it 0 times[0m ./spec/controllers/users_controller_spec.rb:44: current_user is a method from Restful-authentication, which is included in this controller. How am I supposed to test this controller? Thanks in advance

    Read the article

  • Code generation tool, to create C# adapter classes for unit testing?

    - by RyBolt
    I know I wouldn't need this with Typemock, however, with something like MoQ , I need to use the adapter pattern to enable the creation of mocks via interfaces for code I don't control. For example, TcpClient is a .NET class, so I use adapter pattern to enable mocking of this object, b/c I need an interface of that class. I then produce interface ITcpClient, that can then be implemented via a TcpClientAdapter class, which is just plain vanilla adapter pattern implementation. I am looking for a tool to do this automatically (creation of interface and adapter), I would think there is one out there somewhere? (or is everyone just hand coding these)

    Read the article

  • TDD, Unit Test and architectural changes

    - by Leandro
    I'm writing an RPC middleware in C++. I have a class named RPCClientProxy that contains a socket client inside: class RPCClientProxy { ... private: Socket* pSocket; ... } The constructor: RPCClientProxy::RPCClientProxy(host, port) { pSocket = new Socket(host, port); } As you can see, I don't need to tell the user that I have a socket inside. Although, to make unit tests for my proxies it would be necessary to create mocks for sockets and pass them to the proxies, and to do so I must use a setter or pass a factory to the sockets in the proxies's constructors. My question: According to TDD, is it acceptable to do it ONLY because the tests? As you can see, these changes would change the way the library is used by a programmer.

    Read the article

  • Ways to Unit Test Oauth for different services in ruby?

    - by viatropos
    Are there any best practices in writing unit tests when 90% of the time I'm building the Oauth connecting class, I need to actually be logging into the remote service? I am building a rubygem that logs in to Twitter/Google/MySpace, etc., and the hardest part is making sure I have the settings right for that particular provider, and I would like to write tests for that. Is there a recommended way to do that? If I did mocks or stubs, I'd still have to spend that 90% of the time figuring out how to use the service, and would end up writing tests after the fact instead of before...

    Read the article

  • Talks Submitted for Ann Arbor Day of .NET 2010

    - by PSteele
    Just submitted my session abstracts for Ann Arbor's Day of .NET 2010.   Getting up to speed with .NET 3.5 -- Just in time for 4.0! Yes, C# 4.0 is just around the corner.  But if you haven't had the chance to use C# 3.5 extensively, this session will start from the ground up with the new features of 3.5.  We'll assume everyone is coming from C# 2.0.  This session will show you the details of extension methods, partial methods and more.  We'll also show you how LINQ -- Language Integrated Query -- can help decrease your development time and increase your code's readability.  If time permits, we'll look at some .NET 4.0 features, but the goal is to get you up to speed on .NET 3.5.   Go Ahead and Mock Me! When testing specific parts of your application, there can be a lot of external dependencies required to make your tests work.  Writing fake or mock objects that act as stand-ins for the real dependencies can waste a lot of time.  This is where mocking frameworks come in.  In this session, Patrick Steele will introduce you to Rhino Mocks, a popular mocking framework for .NET.  You'll see how a mocking framework can make writing unit tests easier and leads to less brittle unit tests.   Inversion of Control: Who's got control and why is it being inverted? No doubt you've heard of "Inversion of Control".  If not, maybe you've heard the term "Dependency Injection"?  The two usually go hand-in-hand.  Inversion of Control (IoC) along with Dependency Injection (DI) helps simplify the connections and lifetime of all of the dependent objects in the software you write.  In this session, Patrick Steele will introduce you to the concepts of IoC and DI and will show you how to use a popular IoC container (Castle Windsor) to help simplify the way you build software and how your objects interact with each other. If you're interested in speaking, hurry up and get your submissions in!  The deadline is Monday, April 5th! Technorati Tags: .NET,Ann Arbor,Day of .NET

    Read the article

  • C# Domain-Driven Design Sample Released

    - by Artur Trosin
    In the post I want to declare that NDDD Sample application(s) is released and share the work with you. You can access it here: http://code.google.com/p/ndddsample. NDDDSample from functionality perspective matches DDDSample 1.1.0 which is based Java and on joint effort by Eric Evans' company Domain Language and the Swedish software consulting company Citerus. But because NDDDSample is based on .NET technologies those two implementations could not be matched directly. However concepts, practices, values, patterns, especially DDD, are cross-language and cross-platform :). Implementation of .NET version of the application was an interesting journey because now as .NET developer I better understand the differences positive and negative between these two platforms. Even there are those differences they can be overtaken, in many cases it was not so hard to match a java libs\framework with .NET during the implementation. Here is a list of technology stack: 1. .net 3.5 - framework 2. VS.NET 2008 - IDE 3. ASP.NET MVC2.0 - for administration and tracking UI 4. WCF - communication mechanism 5. NHibernate - ORM 6. Rhino Commons - Nhibernate session management, base classes for in memory unit tests 7. SqlLite - database 8. Windsor - inversion of control container 9. Windsor WCF facility - for better integration with NHibernate 10. MvcContrib - and in particular its Castle WindsorControllerFactory in order to enable IoC for controllers 11. WPF - for incident logging application 12. Moq - mocking lib used for unit tests 13. NUnit - unit testing framework 14. Log4net - logging framework 15. Cloud based on Azure SDK These are not the latest technologies, tools and libs for the moment but if there are someone thinks that it would be useful to migrate the sample to latest current technologies and versions please comment. Cloud version of the application is based on Azure emulated environment provided by the SDK, so it hasn't been tested on ‘real' Azure scenario (we just do not have access to it). Thanks to participants, Eugen Gorgan who was involved directly in development, Ruslan Rusu and Victor Lungu spend their free time to discuss .NET specific decisions, Eugen Navitaniuc helped with Java related questions. Also, big thank to Cornel Cretu, he designed a nice logo and helped with some browser incompatibility issues. Any review and feedback are welcome! Thank you, Artur Trosin

    Read the article

  • How can I get my progress reviewed as a solo junior developer

    - by Oliver Hyde
    I am currently working for a 2 person company, as the solo primary developer. My boss gets the clients, mocks up some png design templates and hands them over to me. This system has been working fine and i'm really enjoying it. The types of projects I work on are for small - medium sized businesses and they usually want a CMS system. Developed from scratch i'll build a customised backend for the client to add/edit/remove categories, tags, products etc and then output them to the front end according to the design template handed to me. As time has gone on, the projects have increased in complexity, with shopping cart / ordering features and other common e-commerce type features. Again, this system has been working fine and i'm really enjoying it. My issue is my personal development as a programmer. I spend a lot of my spare time reading programming blogs, checking through stackexchange, reading suggested programming books (currently on 'The Pragmatic Programmer', really good so far), doing brain exercises (lumosity.com and khanacademy math problems), doing lots of physical exercise and other personal development type activities. I can't help but feel though, that I'm missing out on feedback, critique. My boss is great and never holds back on praise in regards to my work, but he unfortunately is either to busy to check my code, or to be honest, I don't think it's one of his specialties and so can't provide feedback. I want to know what i'm doing wrong and what i'm doing right. Should I be putting that much logic in the controller, am I modulating my code enough etc. So what I have done is developed a little 'Family Budgeting' app and tried to do it as cleanly and effectively as I currently know how. What i'm wanting to know is, is there somewhere I can submit this app, and have some seasoned developers provide feedback. It's not just a subsection of my code like 'codereview.stackexchange' appears to require, it's my entire workflow that I want critiqued. I know this is a lot to ask, and I expect the main advice given will be to look for a job within a team, which is certainly something I will look into later down the track, but for now I want to persist with my current employment situation, but just don't want to develop too many bad habits. Let me know if I can provide any further information to help clarify, or if this isn't the right place for this type of question I apologise in advance. Didn't want to use reddit as I felt this community fosters more well thought out responses.

    Read the article

  • How to TDD test that objects are being added to a collection if the collection is private?

    - by Joshua Harris
    Assume that I planned to write a class that worked something like this: public class GameCharacter { private Collection<CharacterEffect> _collection; public void Add(CharacterEffect e) { ... } public void Remove(CharacterEffect e) { ... } public void Contains(CharacterEffect e) { ... } } When added an effect does something to the character and is then added to the _collection. When it is removed the effect reverts the change to the character and is removed from the _collection. It's easy to test if the effect was applied to the character, but how do I test that the effect was added to _collection? What test could I write to start constructing this class. I could write a test where Contains would return true for a certain effect being in _collection, but I can't arrange a case where that function would return true because I haven't implemented the Add method that is needed to place things in _collection. Ok, so since Contains is dependent on having Add working, then why don't I try to create Add first. Well for my first test I need to try and figure out if the effect was added to the _collection. How would I do that? The only way to see if an effect is in _collection is with the Contains function. The only way that I could think to test this would be to use a FakeCollection that Mocks the Add, Remove, and Contains of a real collection, but I don't want _collection being affected by outside sources. I don't want to add a setEffects(Collection effects) function, because I do not want the class to have that functionality. The one thing that I am thinking could work is this: public class GameCharacter<C extends Collection> { private Collection<CharacterEffect> _collection; public GameCharacter() { _collection = new C<CharacterEffect>(); } } But, that is just silly making me declare what some private data structures type is on every declaration of the character. Is there a way for me to test this without breaking TDD principles while still allowing me to keep my collection private?

    Read the article

  • Code review recommendations and Code Smells

    - by Michael Freidgeim
    Some time ago Twitter told that I am similar to Boris Lipschitz . Indeed he is also .Net programmer from Russia living in Australia. I‘ve read his list of Code Review points and found them quite comprehensive. A few points  were not clear for me, and it forced me for a further reading.In particular the statement “Exception should not be used to return a status or an error code.” wasn’t fully clear for me, because sometimes we store an exception as an object with all error details and I believe it’s a valid approach. However I agree that throwing exceptions should be avoided, if you expect to return error as a part of a normal flow. Related link: http://codeutopia.net/blog/2010/03/11/should-a-failed-function-return-a-value-or-throw-an-exception/ Another point slightly puzzled me“If Thread.Sleep() is used, can it be replaced with something else, ei Timer, AutoResetEvent, etc” . I believe, that there are very rare cases, when anyone using Thread.Sleep in any production code. Usually it is used in mocks and prototypes.I had to look further to clarify “Dependency injection is used instead of Service Location pattern”.Even most of articles has some preferences to Dependency injection, there are also advantages to use Service Location. E.g see http://geekswithblogs.net/KyleBurns/archive/2012/04/27/dependency-injection-vs.-service-locator.aspx. http://www.cookcomputing.com/blog/archives/000587.html  refers to Concluding Thoughts of Martin Fowler The choice between Service Locator and Dependency Injection is less important than the principle of separating service configuration from the use of services within an applicationThe post had a link to excellent article Code Smells of Jeff Atwood, but the statement, that “code should not pass a review if it violates any of the  code smells” sound too strict for my environment. In particular, I disagree with “Dead Code” recommendation “Ruthlessly delete code that isn't being used. That's why we have source control systems!”. If there is a chance that not used code will be required in a future, it is convenient to keep it as commented or #if/#endif blocks with appropriate explanation, why it could be required in the future. TFS is a good source control system, but context search in source code of current solution is much easier than finding something in the previous versions of the code.I also found a link to a good book “Clean Code.A.Handbook.of.Agile.Software”

    Read the article

  • Welcome To The Nashorn Blog

    - by Homma
    ??? ??? jlaskey ??? Nashorn Blog ????????????? https://blogs.oracle.com/nashorn/entry/welcome_to_the_nashorn_blog ???????? ?? ??????????????Nashorn ????????????????????????????????????????????????????????????????????????????? Nashorn ?????????????????????????????????????????????????????? ????? JavaOne ??????????Nashorn ???????????????????????????????? Georges Saab ????????????????????????????????????????????????????????????????? JavaOne ????????????????????????????????? ?Nashorn: JVM ??? JavaScript ????????????? ?????????(????????)??????????????????????????????????????????????????JVM ???????????????????????????????????????????????????????????????? ?Nashorn: JVM ?? JavaScript? ??? Nashorn ???????????????????????????????????????????????????Nashorn ???????????????????????????250 ??????????????????????????Twitter ? Sam Pullara ??? Mustache.js ???????(Rhino ? 20 ?????)???????????NetBeans ? John Ceccarelli ??? Nashorn ? Netbeans ??????????????????????????????? Q & A ???????????????? ?Nashorn JavaScript Team ???? Michel ? Attila ? Marcus ??? Q & A ??????????????(??????????????????????????)?????????? Node.jar ??????????Nashorn + Node.jar ???????????????????????????????? Node.jar ? Akhil ??????????????????? ?Nashorn ? Node ? Java Persistence? Doug Clarke ? Akhil ?????????????????(????????? ???????)?????? Q & A ??????????? 80 ??????? ?????? Node.jar ????????Doug ? Nashorn + JPA ??????? ?????????????Nashorn ????????????????? ????????????????? : Nashorn ? Java ???????? Attila ??????? Dynalink ? Nashorn ??????????????????????????????????????????????????????JVM ???????????????????????????????????? ????JavaOne ?? Java ??????????? JVM ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????? Nashorn ???? how to ?????????????????????????????????????????????? ??????????!

    Read the article

  • Mock RequireJS define dependencies with config.map

    - by Aligned
    Originally posted on: http://geekswithblogs.net/Aligned/archive/2014/08/18/mock-requirejs-define-dependencies-with-config.map.aspxI had a module dependency, that I’m pulling down with RequireJS that I needed to use and write tests against. In this case, I don’t care about the actual implementation of the module (it’s simple enough that I’m just avoiding some AJAX calls). EDIT: make sure you look at the bottom example after the edit before using the config.map approach. I found that there is an easier way. I did not want to change the constructor of the consumer as I had a chain of changes that would have to be made and that would have been to invasive for this task. I found a question on StackOverflow with a short, but helpful answer from “Artem Oboturov”. We can use the config.map from RequireJs to achieve this. Here is some code: A module example (“usefulModule” in Common/Modules/usefulModule.js): define([], function() { "use strict"; var testMethod = function() { ... }; // add more functionality of the module return { testMethod; } }); A consumer of usefulModule example: define([ "Commmon/Modules/usefulModule" ], function(usefulModule) { "use strict"; var consumerModule = function(){ var self = this; // add functionality of the module } }); Using config.map in the html of the test runner page (and in your Karma config –> I’m still trying to figure this out): map: {'*': { // replace usefulModule with a mock 'Common/Modules/usefulModule': '/Tests/Specs/Common/usefulModuleMock.js' } } With the new mapping, Require will load usefulModuleMock.js from Tests/Specs/Common instead of the real implementation. Some of the answers on StackOverflow mentioned Squire.js, which looked interesting, but I wasn’t ready to introduce a new library at this time. That’s all you need to be able to mock a depency in RequireJS. However, there are many good cases when you should pass it in through the constructor instead of this approach.   EDIT: After all that, here’s another, probably better way: The consumer class, updated: define([ "Commmon/Modules/usefulModule" ], function(UsefulModule) { "use strict"; var consumerModule = function(){ var self = this; self.usefulModule = new UsefulModule(); // add functionality of the module } }); Jasmine test: define([ "consumerModule", "/UnitTests/Specs/Common/Mocks/usefulModuleMock.js" ], function(consumerModule, UsefulModuleMock){ describe("when mocking out the module", function(){ it("should probably just override the property", function(){ var consumer = new consumerModule(); consumer.usefulModule = new UsefulModuleMock(); }); }); });   Thanks for letting me think out loud :-).

    Read the article

  • Dealing with coworkers when developing, need advice [closed]

    - by Yippie-Kai-Yay
    I developed our current project architecture and started developing it on my own (reaching something like, revision 40). We're developing a simple subway routing framework and my design seemed to be done extremely well - several main models, corresponding views, main logic and data structures were modeled "as they should be" and fully separated from rendering, algorithmic part was also implemented apart from the main models and had a minor number of intersection points. I would call that design scalable, customizable, easy-to-implement, interacting mostly based on the "black box interaction" and, well, very nice. Now, what was done: I started some implementations of the corresponding interfaces, ported some convenient libraries and wrote implementation stubs for some application parts. I had the document describing coding style and examples of that coding style usage (my own written code). I forced the usage of more or less modern C++ development techniques, including no-delete code (wrapped via smart pointers) and etc. I documented the purpose of concrete interface implementations and how they should be used. Unit tests (mostly, integration tests, because there wasn't a lot of "actual" code) and a set of mocks for all the core abstractions. I was absent for 12 days. What do we have now (the project was developed by 4 other members of the team): 3 different coding styles all over the project (I guess, two of them agreed to use the same style :), same applies to the naming of our abstractions (e.g CommonPathData.h, SubwaySchemeStructures.h), which are basically headers declaring some data structures. Absolute lack of documentation for the recently implemented parts. What I could recently call a single-purpose-abstraction now handles at least 2 different types of events, has tight coupling with other parts and so on. Half of the used interfaces now contain member variables (sic!). Raw pointer usage almost everywhere. Unit tests disabled, because "(Rev.57) They are unnecessary for this project". ... (that's probably not everything). Commit history shows that my design was interpreted as an overkill and people started combining it with personal bicycles and reimplemented wheels and then had problems integrating code chunks. Now - the project still does only a small amount of what it has to do, we have severe integration problems, I assume some memory leaks. Is there anything possible to do in this case? I do realize that all my efforts didn't have any benefit, but the deadline is pretty soon and we have to do something. Did someone have a similar situation? Basically I thought that a good (well, I did everything that I could) start for the project would probably lead to something nice, however, I understand that I'm wrong. Any advice would be appreciated, sorry for my bad english.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12  | Next Page >