Skip to content

Commit

Permalink
修改为Jekyll支持的代码格式
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry committed Oct 13, 2014
1 parent 1add5a8 commit 606f867
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions _posts/2014-10-11-weekly.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,21 @@ ps:在stm中使用定时器好麻烦,如果没有模板照着写的话很容

什么也不说,先上代码

``` scala
{% highlight scala %}
try {
……
} catch {
case e: Throwable => Assert.assertFalse(e.isInstanceof[XXXXXXX])
}
```
``` scala
{% endhighlight %}

{% highlight scala %}
try {
……
} catch {
case e: XXXXXXX => //正常应该抛出的异常
}
```
{% endhighlight %}

本身Assert就是抛出异常,然后被自己写的第一段代码先截获 然后再抛出新的异常,这不但是多余的,而且还改变了原来的异常,如果提示的信息不正确,将给调试带来麻烦。

Expand All @@ -86,22 +87,22 @@ ps:在stm中使用定时器好麻烦,如果没有模板照着写的话很容

## @tice9982: 单元测试 注入

``` scala
{% highlight scala %}
new Session(id) with ParaisoSession with TextSession {
……
final def outgoingService[ServiceInterface]( implicit entry: RpcSession.OutgoingProxyEntry[ServiceInterface]): ServiceInterface = {
//网络处理
}
}
```
{% endhighlight %}

``` scala
{% highlight scala %}
new ParaisoSession{
……
final def outgoingService[Service](implicit entry: com.qifun.bcp.rpc.RpcSession.OutgoingProxyEntry[Service]): Service = {
assertEquals(XXXXXXX,XXXXXXXXX)
}
}
```
{% endhighlight %}

注入框架很方便实现接口的替换,从而跳过网络模块直接调用测试代码,一个单元测试思路

0 comments on commit 606f867

Please sign in to comment.