我尝试用maven创建一个测试项目,unit testing工作正常。 但是,当尝试为j2ee项目执行相同操作时,无法通过surefire找到unit testing。 测试位于正确的目录(src / test / java)中,并且正在编译它们。 junit测试位于src / test / java / unit / TestAddition.java pom.xml中的surefire插件配置不包含/排除任何文件。 org.apache.maven.plugins maven-surefire-plugin 2.8 和junit,testng junit junit 4.8.2 test org.testng testng 6.0.1 test 这是“ mvn clean test ”的输出 [DEBUG] (s) reportFormat = brief [DEBUG] (s) reportsDirectory = c:\workspace\JAdaptivLatest\target\surefire-reports [DEBUG] (s) runOrder = filesystem [DEBUG] (s) session = […]
我正在尝试在IID8.5上设置JUnit框架。 但是当我尝试运行简单的JUnit测试用例时,我收到运行时错误。 ( java.lang.NoClassDefFoundError:org.eclipse.core.runtime.RegistryFactory ) 我正在使用JUnit4。 请查看显示项目结构的附图 **Code in BOUtils.java ** package com.wf.utils; import com.ibm.websphere.bo.BOFactory; import com.ibm.websphere.sca.ServiceManager; import com.ibm.websphere.sca.Service.*; public class BOUtils { /** * @param args */ public static void createBusinessObject() { System.out.println(“Create Business Object”); BOFactory boFactory = (BOFactory) new ServiceManager().locateService(“com/ibm/websphere/bo/BOFactory”); } public static void main(String[] args) { // TODO Auto-generated method stub } […]
我有几百万个测试包,有很多测试,我想只运行一些软件包。 现在我必须运行整个项目(一些测试需要很长时间才能完成)或者我需要手动运行每个文件。 如何在NetBeans中运行一些包? 我找不到这个选项……
我在我的Spring MVC控制器上做junit – @RequestMapping(value = “index”, method = RequestMethod.GET) public HashMap handleRequest() { HashMap model = new HashMap(); String name = “Hello World”; model.put(“greeting”, name); return model; } 以下是我对上述方法的说法 – public class ControllerTest { private MockMvc mockMvc; @Before public void setup() throws Exception { this.mockMvc = standaloneSetup(new Controller()).build(); } @Test public void test01_Index() { try […]
问题:我需要调整Android Developer TestSuite示例中的代码,以便它运行包中的所有TestCase,除了一些明确定义的TestCase。 目前它只运行它们: public class AllTests extends TestSuite { public static Test suite() { return new TestSuiteBuilder(AllTests.class) .includeAllPackagesUnderHere() .build(); } } 看一下TestSuiteBuilder的Docs ,也许我可以通过添加对TestSuiteBuilder的addRequirements()方法的调用来调整上面的代码,但是如果这样做的话,我不能做出正面或反面,或者应该用它来做。 如果addRequirements将用于排除AndroidTestCases,我该如何调用它? 我不明白我会通过什么论点,文件说: addRequirements(Predicate… predicates) //Exclude tests that fail to satisfy all of the given predicates. 但我找不到关于类Predicate的存在或者应该如何填充以实现我的目标的任何内容。 谢谢
我在JUnit中有很长的包名,这使得很难看到正在运行的测试。 不幸的是,使用Eclipse的“缩写包名称”不起作用。 有没有办法隐藏或最好缩短它们?
我有大项目,许多人忽略了unit testing。 有没有什么方法可以使用surefire maven插件运行所有被忽略的测试并查看通过的测试列表? 忽略的测试总数> 1000,因此,手动不可能。
我正在尝试为Custom Aspect编写Integratation测试。 这是Aspect Class Snippet。 @Aspect @Component public class SampleAspect { private static Logger log = LoggerFactory.getLogger(SampleAspect.class); private int count; public int getCount(){ return count; } public void setCount(){ this.count= count; } @Around(“execution(* org.springframework.data.mongodb.core.MongoOperations.*(..)) || execution(* org.springframework.web.client.RestOperations.*(..))”) public Object intercept(final ProceedingJoinPoint point) throws Throwable { logger.info(“invoked Cutom aspect”); setCount(1); return point.proceed(); } } 因此,只要关节点与切入点匹配,上述方面就会截获。 它的工作正常。 […]
能帮助我更好地理解,“断言”与“抛出exception”的适当用法是什么? 每个场景何时适用? 情景1 码 public Context(Algorythm algo) { if (algo == null) { throw new IllegalArgumentException(“Failed to initialize Context”); } this.algo = algo; } 测试 public void testContext_null() { try { context = new Context(null); fail(); } catch (IllegalArgumentException e) { assertNotNull(e); } } 场景2 码 public Context(Algorythm algo) { assert (algo != null); this.algo […]
最新消息:有没有人遇到过这个问题? 我在Maven项目中使用JUnit 4.5和Mockito 1.7。 我在testCaseFolder包中有testCaseA.java。 如果我打开testCaseA.java,右键单击代码,选择“Run as” – “Junit test”即可。 但如果我右键单击包,选择“运行方式” – “Junit测试”,它将失败: org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Misplaced argument matcher detected! Somewhere before this line you probably misused Mockito argument matchers. For example you might have used anyObject() argument matcher outside of verification or stubbing. Here are examples of correct usage of argument matchers: when(mock.get(anyInt())).thenReturn(null); doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject()); verify(mock).someMethod(contains(“foo”)); […]