java unit test code_Practically Groovy: Unit test your Java code faster with Groovy

No more Java purism!

Before I launch into the practical aspects of unit testing with Groovy, I think it’s important to talk about the more general issue of its place in your development toolbox. The fact is, Groovy isn’t the only scripting language that runs on the Java Runtime Environment (JRE), it’s just the only one that has been proposed as a standard language for the Java platform. As some of you will have learned from the alt.lang.jreseries (see Resources), there are myriad options when it comes to scripting for the Java platform, most of them presenting highly agile environments for rapid application development.

Despite this abundance of choices, many developers choose to stick with their favorite and most-familiar paradigm: the Java language. While Java programming is a fine choice for most situations, there is one very important shortcoming to wearing Java-only blinders. As a wise person once put it: If the only tool you have is a hammer, you tend to see every problem as a nail. I think there’s a lot of truth to this saying that is applicable to software development.

Just as I hope to convince you with this series that the Java

language is not and should not be your only choice for developing

applications, it’s also true that scripting languages make sense in some

scenarios and not in others. What separates the professional from the

tyro is knowing when to apply the power of scripting and

when to eschew it.

const ServerParam & SP = ServerParam::i(); const int self_min = wm.interceptTable()->selfReachCycle(); const int mate_min = wm.interceptTable()->teammateReachCycle(); int opp_min = wm.interceptTable()->opponentReachCycle(); const PlayerObject * opp_fastest = wm.interceptTable()->fastestOpponent(); if ( opp_fastest && opp_fastest->goalie() && wm.gameMode().isPenaltyKickMode() && opp_fastest->pos().dist( wm.ball().pos() ) >= 3.0 ) // MAGIC NUMBER { M_tackle_situation = false; M_opponent_ball = false; dlog.addText( Logger::TEAM, __FILE__":(update) penalty shootouts. not a tackle situation" ); return; } if ( opp_fastest && wm.gameMode().isPenaltyKickMode() && ! opp_fastest->goalie() ) { const AbstractPlayerObject * opponent_goalie = wm.getTheirGoalie(); if ( opponent_goalie ) { /* //yz del std::map< const AbstractPlayerObject*, int >::const_iterator player_map_it = wm.interceptTable()->playerMap().find( opponent_goalie ); if ( player_map_it != wm.interceptTable()->playerMap().end() ) { // considering only opponent goalie in penalty-kick mode opp_min = player_map_it->second; dlog.addText( Logger::TEAM, __FILE__":(update) replaced min_opp with goalie's reach cycle (%d).", opp_min ); } else { opp_min = 1000000; // practically canceling the fastest non-goalie opponent player dlog.addText( Logger::TEAM, __FILE__":%d: (update) set opp_min as 1000000 so as not to consider the fastest opponent.", __LINE__ ); } */ } else { opp_min = 1000000; // practically canceling the fastest non-goalie opponent player dlog.addText( Logger::TEAM, __FILE__":%d (update) set opp_min as 1000000 so as not to consider the fastest opponent.", __LINE__); } }
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值