{"action":"created","issue":{"url":"https://api.github.com/repos/jfinal/jfinal/issues/60","labels_url":"https://api.github.com/repos/jfinal/jfinal/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/jfinal/jfinal/issues/60/comments","events_url":"https://api.github.com/repos/jfinal/jfinal/issues/60/events","html_url":"https://github.com/jfinal/jfinal/issues/60","id":70122610,"number":60,"title":"如何对Model进行单元测试?","user":{"login":"xurenlu","id":83189,"avatar_url":"https://avatars.githubusercontent.com/u/83189?v=3","gravatar_id":"","url":"https://api.github.com/users/xurenlu","html_url":"https://github.com/xurenlu","followers_url":"https://api.github.com/users/xurenlu/followers","following_url":"https://api.github.com/users/xurenlu/following{/other_user}","gists_url":"https://api.github.com/users/xurenlu/gists{/gist_id}","starred_url":"https://api.github.com/users/xurenlu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xurenlu/subscriptions","organizations_url":"https://api.github.com/users/xurenlu/orgs","repos_url":"https://api.github.com/users/xurenlu/repos","events_url":"https://api.github.com/users/xurenlu/events{/privacy}","received_events_url":"https://api.github.com/users/xurenlu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-22T13:14:52Z","updated_at":"2015-04-23T02:27:14Z","closed_at":"2015-04-23T02:27:14Z","body":"如题,写了这么一段单测代码,但是无法跑起来,\r\n@Test\r\n    public void testUser(){\r\n        User u = new User();\r\n        u.set(\"username\",\"renlu\");\r\n        u.set(\"password\",\"842519\");\r\n        u.set(\"email\",\"xurenlu@gmail.com\");\r\n        long t = (new Date()).getTime()/1000;\r\n        u.set(\"created_at\",t);\r\n        u.set(\"updated_at\",t);\r\n        u.save();\r\n    }\r\n\r\n如果需要跑这么一段代码,需要运行一个web server实例...\r\n能不能提供一个简单点的能运行单测的case?"},"comment":{"url":"https://api.github.com/repos/jfinal/jfinal/issues/comments/95395875","html_url":"https://github.com/jfinal/jfinal/issues/60#issuecomment-95395875","issue_url":"https://api.github.com/repos/jfinal/jfinal/issues/60","id":95395875,"user":{"login":"jfinal","id":1677603,"avatar_url":"https://avatars.githubusercontent.com/u/1677603?v=3","gravatar_id":"","url":"https://api.github.com/users/jfinal","html_url":"https://github.com/jfinal","followers_url":"https://api.github.com/users/jfinal/followers","following_url":"https://api.github.com/users/jfinal/following{/other_user}","gists_url":"https://api.github.com/users/jfinal/gists{/gist_id}","starred_url":"https://api.github.com/users/jfinal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfinal/subscriptions","organizations_url":"https://api.github.com/users/jfinal/orgs","repos_url":"https://api.github.com/users/jfinal/repos","events_url":"https://api.github.com/users/jfinal/events{/privacy}","received_events_url":"https://api.github.com/users/jfinal/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T02:27:14Z","updated_at":"2015-04-23T02:27:14Z","body":"在初始化方法中创建 ActiveRecordPlugin 对象，并且 arp.start() 启动它即可开始使用 ActiveRecordPlugin，具体方法可看这里：http://www.oschina.net/question/173052_59956。另外，jfinal 单元测的一些支持可以看下这里：http://git.oschina.net/zhouleib1412/jfinal-ext/tree/master/src/main/java/com/jfinal/ext/test，这里面有辅助单元测试使用的 Mock 类"}}