全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 winbugs及其他软件专版
2477 12
2015-04-12


JRuby Cookbook


Book Description
If you're interested in JRuby, you probably don't need a turorial on Ruby, Rails, or Java - you just need to know how to get things done. This Cookbook offers practical solutions for using the Java implementation of the Ruby language, with targeted recipes for deploying Rails web applications on Java servers, integrating JRuby code with Java technologies, developing JRuby desktop applications with Java toolkits, and more.
Book Details
Publisher:        O'Reilly Media
By:        Justin Edelson, Henry Liu
ISBN:        978-0-59651-980-3
Year:        2008
Pages:        224
Language:        English
File size:        3.9 MB
File format:        PDF
eBook
Download:       

本帖隐藏的内容

JRuby Cookbook.pdf
大小:(3.69 MB)

只需: 20 个论坛币  马上下载



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-6-21 03:22:13
提示: 作者被禁止或删除 内容自动屏蔽
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-6-21 09:51:37
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-6-21 10:36:50
Creating Mock Objects with Mocha

Problem

You want to test a Java class that has dependencies on other classes and want to insulate your tests from changes in the behavior of those other classes.


Solution

Use Mocha, a Ruby mocking and stubbing framework that is included with JtestR. Mocha allows you to create instances of Java interfaces and classes that exhibit a specific behavior. Mock objects can be used in any type of test supported by JtestR. In Example 7-8, Mocha is used to create a mock instance ofjava.util.Collection, which is passed to an instance of java.util.ArrayList. This test validates the behavior of the retainAll() method, specifically that it calls thecontains() method on the supplied Collection object the correct number of times.

Example 7-8. Unit test with dust and Mocha
复制代码





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-6-21 14:41:18
Testing Java Code with RSpec

Problem

You want to write behavior-orientated tests for your Java code.


Solution

Use JtestR’s support for the RSpec Behavior-Driven Development (BDD) framework. RSpec is actually composed of two different frameworks for writing tests: the Spec framework and the Story framework.

Spec framework

RSpec Spec tests describe the behavior of an object through a series of assertions about the behavior of the object. These assertions are referred to as examples. The Spec file in Example 7-5 describes the behavior of the java.util.HashSet class.

Example 7-5. RSpec Spec file for java.util.HashSet
复制代码






二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-6-21 20:31:13
Unit Testing Java Code with Expectations

Problem

You want to test your Java code using a more concise syntax than is available from Java testing frameworks such as JUnit and TestNG and want to ensure you follow some testing best practices, specifically limiting the number of assertions per test to one.


Solution

Use JtestR’s support for the Expectations framework. Like dust, Expectations provides a domain-specific language (DSL) for writing tests. Unlike dust, Expectations does not use the standard Test/Unit assertion methods. Instead, each test makes an assertion about the return value of the test. Example 7-4 contains the same tests seen in prior recipes using Expectations.

Example 7-4. Unit testing with Expectations
复制代码





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群