Giter Site home page Giter Site logo

Practise TDD please. about gulp-git HOT 9 CLOSED

steida avatar steida commented on August 20, 2024
Practise TDD please.

from gulp-git.

Comments (9)

stephenlacy avatar stephenlacy commented on August 20, 2024

You do know that I need to get the tests to pass Travis. It is a pain to enable git to function on travis, thus the removal of several tests such as push.
Common, be respectable with other projects.

Thank you.

from gulp-git.

steida avatar steida commented on August 20, 2024

Sorry, I was angry. Thank you for your work.

from gulp-git.

stephenlacy avatar stephenlacy commented on August 20, 2024

It's alright, thanks for telling me about the issues.

from gulp-git.

steida avatar steida commented on August 20, 2024

Take a look at https://github.com/steida/este how Travis is enabled on git project. It's easy. Just enable per project here: https://travis-ci.org/profile, add travis file, point npm test to gulp or mocha. Done.

from gulp-git.

stephenlacy avatar stephenlacy commented on August 20, 2024

Yes, I have it enabled. What I was mentioning was git runs very slow on a travis box. Usually longer than a usual 2000ms mocha timeout. In order to test the git push I would need to add a git user and credentials.
As you can see I have mocha tests, only for the ones which do not require a git user: https://github.com/stevelacy/gulp-git/blob/master/test/main.js

from gulp-git.

steida avatar steida commented on August 20, 2024

I think I can help you. The reason why we prefer unit tests over integration tests (they are still great, but should be written after unit tests) is: Mockup boundaries.

You should not test git itself. It works, and we all know it. Instead, mock how you call it. Probably exec. How to do it? Add optional parameter into constructor or method (it is called poor man DI).

doSomethingWithGit = function(someParams, opt_exec) {
exec = exec || opt_exec;
}

With such aproach, you can mock exec/git cmd behaviour. As result, tests will be super fast and easy to write.

Hope this helps.

from gulp-git.

steida avatar steida commented on August 20, 2024

You need integration tests only when you are going across boundaries. http://blog.8thlight.com/uncle-bob/2014/04/30/When-tdd-does-not-work.html

from gulp-git.

steida avatar steida commented on August 20, 2024

Feel free to ask if something is not obvious.

from gulp-git.

xixixao avatar xixixao commented on August 20, 2024

@steida You don't need mocking to test that behavior (2nd error). That said, the error would most likely not occur if the source was in idomatic CoffeeScript instead of JS:

    exec cmd, cwd: cwd, (err, stdout, stderr) =>
      cb err if err
      gutil.log stdout, stderr
      @push file for file in files
      cb()

Nice example.

from gulp-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.