注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

阿弥陀佛

街树飘影未见尘 潭月潜水了无声 般若观照心空静...

 
 
 

日志

 
 
关于我

一直从事气象预报、服务建模实践应用。 注重气象物理场、实况场、地理信息、本体知识库、分布式气象内容管理系统建立。 对Barnes客观分析, 小波,计算神经网络、信任传播、贝叶斯推理、专家系统、网络本体语言有一定体会。 一直使用Java、Delphi、Prolog、SQL编程。

网易考拉推荐

ScalaTest User Guide2  

2014-07-04 23:16:53|  分类: Scala |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
ScalaTest User Guide

Getting started

Selecting testing styles

Defining base classes

Writing your first test

Using assertions

Tagging your tests

Running your tests

Sharing fixtures

Sharing tests

Using matchers

Testing with mock objects

Property-based testing

Using Selenium

Other goodies

Philosophy and design

Migrating to 2.0

Defining base classes for your project

ScalaTest is a testing toolkit: it consists of focused, lightweight traits that you can mix together to solve the problem at hand. This approach minimizes the potential for naming and implicit conflicts and helps speed compiles.

Instead of duplicating code by mixing the same traits together repeatedly, we recommend you create abstract base classes for your project that mix together the features you use the most. For example, you might create a UnitSpec class (not trait, for speedier compiles) for unit tests that looks like:

package com.mycompany.myproject

import org.scalatest._

abstract class UnitSpec extends FlatSpec with Matchers with
  OptionValues with Inside with Inspectors

You can then write unit tests for your project using the custom base class, like this:

package com.mycompany.myproject

import org.scalatest._

class MySpec extends UnitSpec {
  // Your tests here
}

Most projects end up with multiple base classes, each focused on different kinds of tests. You might have a base class for integration tests that require a database (perhaps named DbSpec), another for integration tests that require an actor system (perhaps named ActorSysSpec), and another for integration test that require both a database and an actor system (perhaps named DbActorSysSpec), and so on. To get started, you can just create a base class for unit testing.

Note that in the rest of the user guide, we don't extend UnitSpec. Instead we show all traits involved to make it clear what is being used and make each example work independently.

With that, it is time to write your first test.

ScalaTest is brought to you by Bill Venners, with contributions from several other folks. It is sponsored by Artima, Inc.
ScalaTest is free, open-source software released under the Apache 2.0 license.

Copyright ? 2009-2013 Artima, Inc. All Rights Reserved.

artima

  评论这张
 
阅读(449)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017