junit

Run all tests in Junit 4

与世无争的帅哥 提交于 2019-12-31 10:03:13
问题 I want to be able to run all tests in a project programmatically. I know Eclipse has a "Run as JUnit test" configuration which somehow grabs all the tests in a project and run them. Is there any way for me to also grab the list of tests programmatically and run them? Or is there some good way to construct a test suite containing all the test cases without manually listing out every one (all 700+) of them? I've tried the "New... -> Test Suite" option in Eclipse, but that seems to work only for

EMMA with Junit, should I be testing with the instrumented classes or java classes?

帅比萌擦擦* 提交于 2019-12-31 07:14:07
问题 I've been going through this tutorial for my ANT Script for emma/junit, it states In the <classpath> element of <junit> , change the locations of your real classes, so that you are pointing at the ${instr.dir} attribute instead of your normal target/classes folder. Here is my emma section from of my build.xml for Apache Ant (pastebin link to full build.xml) <!-- =================================================================== --> <!-- Run the tests with EMMA * depends from compile --> <!--

Variety of issues testing Android Webview using Appium

左心房为你撑大大i 提交于 2019-12-31 07:01:14
问题 I have a hybrid app that is primarily just a webview. Here is the code for the basic test: @BeforeClass public static void setupAppium() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("appium-version", "1.5.3"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("platformVersion", "6.0"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "AppiumTesterDevice"); capabilities

Junit 4.12 Issue testing exception

被刻印的时光 ゝ 提交于 2019-12-31 05:18:06
问题 I have a simple method trying to fetch some file. I would like to test when the file is none existent and this is where my problem begins. The test keeps failing. The method is something like : public Configuration populateConfigs(Configuration config) throws UnRetriableException { try { .... } catch (IOException | ConfigurationException e) { log.error(" getConfiguration : ", e); throw new UnRetriableException(e); } throw new UnRetriableException("problem getting config files."); } In my

Verifying sequence of private method calls in unit testing

穿精又带淫゛_ 提交于 2019-12-31 05:02:26
问题 I have the following class: class MyClass { public void doIt() { methodOne(); methodTwo(); methodThree(); } private void methodOne() { // ... } // rest of methods similar... } My intention is to verify that when i invoke doIt(), methods metodOne(), methodTwo() and methodThree() will be invoked, in that order. I'm using mockito for mocking. Does anyone knows how i can test this scenario? 回答1: Hate to be the person but: simply don't test this. Test the output, side effects, results - not the

Verifying sequence of private method calls in unit testing

落花浮王杯 提交于 2019-12-31 05:02:01
问题 I have the following class: class MyClass { public void doIt() { methodOne(); methodTwo(); methodThree(); } private void methodOne() { // ... } // rest of methods similar... } My intention is to verify that when i invoke doIt(), methods metodOne(), methodTwo() and methodThree() will be invoked, in that order. I'm using mockito for mocking. Does anyone knows how i can test this scenario? 回答1: Hate to be the person but: simply don't test this. Test the output, side effects, results - not the

How to cover block catch by JUnit with NoSuchAlgorithmException and KeyStoreException

久未见 提交于 2019-12-31 04:32:25
问题 I want to cover getKeyStore() methode, But I don't know how to cover catch block for NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException and CertificateException. My methode is : public static KeyManagerFactory getKeyStore(String keyStoreFilePath) throws IOException { KeyManagerFactory keyManagerFactory = null; InputStream kmf= null; try { keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());

JMeter: Read CSV file contents into JUnit testcase program using CSV Data Set Config

孤街醉人 提交于 2019-12-31 04:28:13
问题 I want to use data from CSV file mentioned in CSV Data Set Config of JMeter into my JUnit testcase program and pass that data to test method. I know how to get data from CSV Data Set Config for HTTP Request but couldn't find any help for JUnit Request. My test method is: public void test() throws IOException{ try { CheckUser(UserId);//I want to get this UserId from CSV file mentioned in CSV Data Set Config of JMeter }catch (Exception e) { e.printStackTrace(); fail(); } } I am new to JUnit and

Java EE 7 Portable solution for Integration and Unit testing

谁说胖子不能爱 提交于 2019-12-31 04:23:05
问题 I am trying to find a portable solution to test my Java EE 7 application. It is especially tricky when to test the EJB and their injections. For example: @org.junit.Test public void testIsValidCredentials() throws Exception { System.out.println("isValidCredentials"); String username = ""; String password = ""; Map properties = new HashMap(); properties.put(EJBContainer.MODULES, new File[] {new File("target/classes")}); EJBContainer container = javax.ejb.embeddable.EJBContainer

activiti 基础搭建

血红的双手。 提交于 2019-12-31 03:52:22
首先在eclipse内添加activiti的插件,https://blog.csdn.net/qq_22701869/article/details/79537971 1.创建一个maven的java工程 2.在pom文件内导入下面的包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xfma</groupId> <artifactId>acticvity</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven