NutzCN Logo
问答 activiti中加入Junit测试,这个是什么问题
发布于 1856天前 作者 stone 1452 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.lang.born.BorningException: Fail to born or cast to 'org.nutz.integration.activiti.ActivitiIocLoader'
by args: [@(nutzRunner)]
because: No suitable Constructor or Factory Method!!

at org.nutz.lang.Mirror.born(Mirror.java:1008)
at org.nutz.ioc.loader.combo.ComboIocLoader.createIocLoader(ComboIocLoader.java:120)
at org.nutz.ioc.loader.combo.ComboIocLoader.<init>(ComboIocLoader.java:94)
at org.nutz.mock.NutTestRunner.createIocLoader(NutTestRunner.java:59)
at org.nutz.mock.NutTestRunner.createIoc(NutTestRunner.java:67)
at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:30)
at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
package org.activiti.designer.test;

import nutzRunner.MyNutTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;



@RunWith(MyNutTestRunner.class)
@IocBean
public class MyJunitTest extends Assert {

        @Inject("refer:$ioc")
        protected Ioc ioc;

        @Test
        public void myTest() {
            System.out.println("ceshi helloword");
        }
}

package nutzRunner;
import com.iqingmai.MainModule;
import org.junit.runners.model.InitializationError;
import org.nutz.mock.NutTestRunner;

public class MyNutTestRunner extends NutTestRunner {

    public MyNutTestRunner(Class<?> klass) throws InitializationError {
        super(klass);
    }

    @Override
    protected Class<?> getMainModule() {
        return MainModule.class;
    }
}
5 回复

MainModule写了啥

package com.iqingmai;

import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Encoding;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.IocBy;
import org.nutz.mvc.annotation.Localization;
import org.nutz.mvc.annotation.Modules;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.SetupBy;
import org.nutz.mvc.filter.CheckSession;
import org.nutz.mvc.ioc.provider.ComboIocProvider;

@IocBy(type = ComboIocProvider.class, args = {
		"*json", "ioc/",
		"*anno",
		"com.iqingmai.base/module",
		"com.iqingmai.console/bean",
		"com.iqingmai.console/module",
		"com.iqingmai.system/bean",
		"com.iqingmai.system/module",
		"com.iqingmai.bpm/bean",
        "com.iqingmai.bpm/module",
        "com.iqingmai.util",
		"com.iqingmai.formDesign/constant",
		"com.iqingmai.formDesign/module",
		"com.iqingmai.formDesign/bean",
		"*activiti",
        "nutzRunner"
})
@SetupBy(value = InitSetup.class, args = { "init.js" })
@Encoding(input = "utf8", output = "utf8")
@Modules(scanPackage = true)
@Localization("msg")
@Ok("json")
@Fail("jsp:/base/jsp/error")
@Filters(@By(type = CheckSession.class, args = { BaseModule.SESSION_ID, BaseModule.LOGIN_PAGE }))
public class MainModule {}

"*activiti",
        "nutzRunner"

你这里加个nutzRunner是神马意思

这样写就够用啦

@IocBy(type = ComboIocProvider.class, args = {
		"*json", "ioc/",
		"*anno",
		"com.iqingmai",
		"*activiti"
})

activiti加载器就没参数的

项目是maven结构的nutzRunner是在test中的,所有有个nutzRunner这个包。路径src.test.java下的nutzRunner包

添加回复
请先登陆
回到顶部