Back to site
Since 2004, our University project has become the Internet's most widespread web hosting directory. Here we like to talk a lot about web servers, web development, networking and security services. It is, after all, our expertise. To make things better we've launched this science section with the free access to educational resources and important scientific material translated to different languages.

Mocha


Mocha je biblioteka za mocking i stubbing koristeći sintaksu kao što je JMock.

Može se koristiti zajedno sa mnogim okvirima za testiranje, npr. Test::Unit, RSpec, test/spec, expectations , Dust, MiniTest čak i JtestR .

Mocha pruža jedinstvenu, jednostavanu i čitljivu sintaksu za tradicionalni, kao i za delimični mockiing.

Mocha je nastala od projekata u Reevoo-u od strane mene ( James) i mojih (tadašnjih) kolega Ben-a , Chris-a i Paul-a.

Instalacija


Instalirajte najnoviju verziju “dragulja” sa sledećom komandom ...
$ gem install mocha
Imajte na umu da ako nameravate da koristite Mocha-u uz pomoć Test::Unit ili MiniTest okvira, samo treba da učitate Mocha-u nakon učitavanja relevantne test biblioteke ...
require "test/unit" require "mocha"
Ako koristite Bundler, obezbedite odgovarajući redosled učitavanja ne zahtevajući automatski Mocha-u u Gemfile-u, a kasnije učitajte naredbu još jednom kada znate da je test biblioteka učitana ...
# Gemfile gem "mocha", :require => false # Elsewhere after Bundler has loaded gems require "test/unit" require "mocha"
Imajte na umu da verzije 0.10.2, 0.10.3 i 0.11.0 imaju grešku. Molimo vas da ne koristite ove verzije.

Ili instalirate Rails dodatke.
$ script/plugin install git://github.com/freerange/mocha.git
Imajte na umu da su verzije 0.9.6 i 0.9.7 Rails dodataka bile pokvarene. Od verzije 0.9.8, morate izričito da učitate Mocha-u posle testa okvira npr dodajući “require ‘mocha’” na dno testa ,code>/ test_helper.rb.

Primeri

*Quick Start - Primeri upotrebe
* Tradicionalni mocking - Star Trek Example
*Postavljanje očekivanja na stvarnim klasama - Primer reda
* Više primera na blogu James Mead-a
*Arhiva mejling liste

Copyright © 2006 Revieworld Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.




Published (Last edited): 10-09-2012 , source: http://gofreerange.com/mocha/docs/