junit

IntelliJ: rerun intermittently failing random test with previos run's data

孤人 提交于 2020-01-05 08:09:32
问题 I have a JUnit test class with a number of tests. To increase scenario coverage some data in our tests is randomized, meaning it may take a range of values between individual test runs, for example: protected MonthlyAmountWithRemainder getMonetaryAmountMultipleOf(int multiplier) { BigDecimal monthly = randomBigDecimal(1000); BigDecimal multiply = new BigDecimal(multiplier); BigDecimal total = monthly.multiply(multiply); return new MonthlyAmountWithRemainder(total, monthly, ZERO); } Do you see

IntelliJ: rerun intermittently failing random test with previos run's data

丶灬走出姿态 提交于 2020-01-05 08:08:25
问题 I have a JUnit test class with a number of tests. To increase scenario coverage some data in our tests is randomized, meaning it may take a range of values between individual test runs, for example: protected MonthlyAmountWithRemainder getMonetaryAmountMultipleOf(int multiplier) { BigDecimal monthly = randomBigDecimal(1000); BigDecimal multiply = new BigDecimal(multiplier); BigDecimal total = monthly.multiply(multiply); return new MonthlyAmountWithRemainder(total, monthly, ZERO); } Do you see

How to dynamically specify the package to @RunWith with JUnit4

不想你离开。 提交于 2020-01-05 07:05:27
问题 Thanks to my previous question, my framework now has a runner that will count @Category tags so I can get a clear picture of code coverage from my testing. My next step is to abstract the runner as the one framework handles multiple apps, divided into packages. +---main +---test +---java +---com +---company +---app ¦ +---app1 ¦ ¦ +---common ¦ ¦ +---page ¦ ¦ +---test ¦ +---app2 ¦ +---common ¦ +---page ¦ +---test +---core +---categories The framework uses PageObject Model so page will contain

how to configure the name and classname attributes on the JUnit XML report

倖福魔咒の 提交于 2020-01-05 06:15:44
问题 In order to integrate with an external test management solution and have visibility of karate results, I need to import them using the JUnit XML report. Test cases identified in JUnit's XML report are identified by the name and classname attributes on the element. However, it seems that these names are being generated somehow dynamicaly and not as unique identifiers that clearly identify the original testcase. The ideal case would be to have unique identifiers for the corresponding testcases,

Jenkins Error: No test report files were found. Configuration error?

强颜欢笑 提交于 2020-01-05 05:35:08
问题 I can't figure out why I have this error. I've installed ant via jenkins on windows. My project is called test-freestyle and is held at: C:\Program Files (x86)\Jenkins\workspace\test-freestyle I've manually created an empty Reports folder inside that test-freestyle folder and am trying to follow this tutorial and this StackOverflow post to troubleshoot. Here is the folder structure, proof that jenkins sees the directory build failure image Is it becasue Program Files needs admin rights to

Mock elastic search data

这一生的挚爱 提交于 2020-01-05 05:29:05
问题 How do I mock elastic search data. In the below code rs is an interface which is implemented by ElasticSearchDriver class. rs will have elastic search db details which inturn gets added in the results. While writing unit tests for this code how do we mock the elastic search data. ListThread listThread = new ListThread(rs, index, QueryMap, sortOrder) results.add(executor.submit(listThread)); 来源: https://stackoverflow.com/questions/40084131/mock-elastic-search-data

Gradle reports BUILD SUCCESSFUL, however I can not locate any .class files

ぐ巨炮叔叔 提交于 2020-01-05 04:41:12
问题 I am attempting to use Gradle (for the first time) for a multiproject java build. I have created a settings.gradle file with all the project names. I have also create a very basic build.gradle file. To my surprise when I run gradle build. It returns BUILD SUCCESSFUL. Jars are created in the build\libs folder. What is puzzling to me is that no .class files exists. Also I have been unable to get any kind of Junit results or xml output. I'm wondering if this is really building correctly. For now

Spring jdbcTemplate Junit

天涯浪子 提交于 2020-01-05 04:07:11
问题 I have one application with DAO as follows. I want to junit this class. My Class looks like this. public class DaoImpl implements Dao{ @Override public User getUserInfo(String userid) { return getTemplate().queryForObject(QUERY, new Object[] { userid }, new BeanPropertyRowMapper<User>(User.class)); } } My junit class looks like this @RunWith(SpringJUnit4ClassRunner.class) public class DaoImplTests{ @Autowired private Dao dao; @Mock JdbcTemplate jdbcTemplate; @Test public void testUsingMockito

How To Java Unit Test a Complex Class

匆匆过客 提交于 2020-01-05 03:57:13
问题 I'm experiencing a difficult time on figuring out how to approach a problem with unit testing. I have little to no 'unit testing' experience. I am trying to change the classUnderTest only if absolutely necessary with minimal changes. I am using JUnit 4, and I am willing to try to use Mockito, JMockit or any other libraries that would help with efficient and effectively unit testing. I am using JDBC for the database. Problem: Within the classUnderTest , I'm accessing a static database.

How to run a single method in a JUnit 4 test class? [duplicate]

走远了吗. 提交于 2020-01-05 02:25:11
问题 This question already has answers here : Run single test from a JUnit class using command-line (3 answers) Closed 6 years ago . I have looked at all the similar questions, but in my opinion, none of them give a solid answer to this. I have a test class (JUnit 4 but also interested in JUnit 3) and I want to run individual test methods from within those classes programmatically/dynamically (not from the command line). Say, there are 5 test methods but I only want to run 2. How can I achieve