junit

Is there a way to separate long running (e.g. stress tests) out so they're not run by default in Maven 2?

筅森魡賤 提交于 2019-12-20 09:55:25
问题 We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation. Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build. Of course we can use the surefire plugin's exclusion mechanism and just punt them from the build, but ideally we'd love something that would allow the developer to run them at will through Maven

Where to put spring configuration files when using maven

一个人想着一个人 提交于 2019-12-20 09:46:49
问题 I'm trying to solve my configuration-files-problem. I have Spring MVC application with this structure (my current structure) src/main/java/ ....................... (java classes) src/main/resources/ .................. (some .properties files ) src/main/webapp/ ..................... (web content, web.xml ) src/main/webapp/spring/ .............. (other spring config files, app-confix.xml, etc.) src/main/webapp/myApp-servlet.xml .... (servlet config) src/test/java ........................ (java

Selenium 2 and JUnit4: How to capture screenshot on exception?

柔情痞子 提交于 2019-12-20 09:38:27
问题 I want to capture a screenshot only upon unexpected exception. 回答1: Note.- This answer could be outdated. The answer is based on Selenium 2.15 Using TestWatcher does the trick (the unit test must extend following BaseTest ): public abstract class BaseTest { // ... protected WebDriver driver; @Rule public TestRule testWatcher = new TestWatcher() { @Override public void starting(Description desc) { LOG.info("Launching browser..."); driver = Utils.getFirefoxDriver(); } @Override public void

Android Studio import existing unit tests “Unable to find instrumentation info”

亡梦爱人 提交于 2019-12-20 09:26:09
问题 So I'm trying our Android Studio and testing a project that worked in eclipse. I got everything compiling and the application will launch just fine, but I can't get my unit tests up and working. I eventually got them compiling by adding my applications lib folder as a dependency, but I don't think my run configuration is right because whenever I run my tests I get this error Installing <packagename> DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/<packagename>" pkg: /data/local/tmp/

AssertNull should be used or AssertNotNull

◇◆丶佛笑我妖孽 提交于 2019-12-20 09:13:57
问题 This is a pretty dumb question but my first time with unit testing so: lets say I have an object variable like obj and I want my unit test to Fail if this obj is Null. so for assertions, should I say AssertNull or AssertNotNull ? I get confused how they are named. 回答1: Use assertNotNull(obj) . assert means must be . 回答2: The assertNotNull() method means "a passed parameter must not be null ": if it is null then the test case fails. The assertNull() method means "a passed parameter must be

How to get entered text from a textbox in selenium

孤街醉人 提交于 2019-12-20 09:12:00
问题 I enter a value in TextBox or a Combobox, and would like to retrieve the value I have just entered. I see that Selenium Weblement method 'getText()' doesnt retrieve the value, it seems the entered text doesn't get pushed into DOM. Any Solutions ? 回答1: The getText() method is for retrieving a text node between element tags for example: <p>Something</p> getText() will return "Something" In a textbox typed text goes into the value attribute so you can try something like: findElement(By.id(

Spring Boot properties in 'application.yml' not loading from JUnit Test

≡放荡痞女 提交于 2019-12-20 09:10:03
问题 What am I doing wrong? I'm using this little standalone App which runs and finds my src/main/resources/config/application.yml . The same configuration doesn't work from JUnit, see below: @Configuration @ComponentScan @EnableConfigurationProperties public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class); } } @Component @ConfigurationProperties public class Bean{ ... } The following doesn't work, the same properties in application.yml

spring Should I use @DirtiesContext on every class

拥有回忆 提交于 2019-12-20 09:05:15
问题 I have several junit tests, @ContextConfiguration(locations = { "file:../business/src/test/resources/application-context-test.xml", "file:src/main/webapp/WEB-INF/confA.xml", "classpath:/mvc-dispatcher-servlet-test.xml"}) @WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class ProductContentControllerTest { ... } Inside a class all tests have to run in the same context (which is the case). But I want all my tests classes to be independent. I was assuming that it was the

Java/ JUnit - AssertTrue vs AssertFalse

让人想犯罪 __ 提交于 2019-12-20 08:24:16
问题 I'm pretty new to Java and am following the Eclipse Total Beginner's Tutorials. They are all very helpful, but in Lesson 12, he uses assertTrue for one test case and assertFalse for another. Here's the code: // Check the book out to p1 (Thomas) // Check to see that the book was successfully checked out to p1 (Thomas) assertTrue("Book did not check out correctly", ml.checkOut(b1, p1)); // If checkOut fails, display message assertEquals("Thomas", b1.getPerson().getName()); assertFalse("Book was

JUnit 4 vs TestNG - Update 2013 - 2014 [closed]

家住魔仙堡 提交于 2019-12-20 08:09:32
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . JUnit 4 and TestNG used to be comparable. What are the pros and cons of the two testing frameworks? 回答1: I was comparing TestNG and JUnit4 today, and the main advantage that I can point out with my limited experience in testing-frameworks is that TestNG has a more elegant way