One of my test case is failed where I should get element not found exception but there is no such exception thrown and all my test cases are shown as passed .Using intellij community version,can anybody help me out of this???
Thanks in advance....
I have checked POM and testNG xml but all seems to be proper.
try using the #Test annotation:
#Test(expected = IllegalArgumentsException.class)
Related
I've got a Domain Driven Design solution and for some reason, I'm getting this exception at RunTime when the API call is made through GateWay:
One or more errors occurred. (Method not found: 'Void FluentValidation.AbstractValidator`1.When(System.Func`2<!0,Boolean>, System.Action)'.)
The error occurs as below:
I have solution like this:
The main 4 project I'm focusing on right now are:
Core.Model
Account.Api
Service.Api.Gateway
Web.ClientSite
Web.ClientSite makes request to Service.Api.Gateway which then calls Account.Api.
Note that Core.Model is referenced everywhere
VERY IMPORTANT: If I remove the reference of FluentValidation from Core.Model, the exception disappears.
I'm hoping these information is enough. Why do you think I'm getting this exception and how can I eliminate.
Looks like some of libs (ocelot) are incompatible with new changes in FluentValidation 8.1.2. Try to downgrade to FluentValidation before 8.1.2. Hope it helps
I got similar exception:
System.MissingMethodException : Method not found:
'FluentValidation.AssemblyScanner
FluentValidation.AssemblyScanner.FindValidatorsInAssembly(System.Reflection.Assembly)'
In my case I needed to upgrade the ediatR.Extensions.Microsoft.DependencyInjection and MediatR.Extensions.FluentValidation.AspNetCore packages as well to fix the issue.
My below code works well with Java 1.7 and Mockito version is 1.10.19.
#Test
public void populateUsersEmpty() {
// arrange
List<UserDTO> users = new ArrayList<UserDTO>();
// act
requestBuilder.populateUsers(mxsMessageOutMock, users);
// assert
verify(mxsMessageOutMock, times(0)).addRecordSet(CreateNewAlertRequestBuilder.MXS_RECORDSETNAME_USERS);
verify(mxsMessageOutMock, times(0)).addFieldNewRecord(anyString(), anyString());
verify(mxsMessageOutMock, times(0)).addField(anyString(), any());
}
But when I moved to Java 1.8 with same version of Mockito it started showing below error (bold letters). When I checked Mockito website I found that Mockito 3 yet to support java 8. If yes,then what is solution for this? Should I have to wait for their release or Is there any way to fix this. I tried passing AnyString() in place of any() but my code breaks still. Even anyObject() didn't help me.
verify(mxsMessageOutMock, times(0)).addField(anyString(), anyString());
CreateNewAlertRequestBuilderTest.java:436:0::0 The method addField(String, String) is ambiguous for the type IMXSMessageOut
[ant:iajc] [error 7]: error at verify(mockMessageOut, times(0)).addField(anyString(), any());
I understand that Its difficult to suggest without full code but here what I could share piece of code.
any(String.class)? if addField is accepting String, String why don't u use anyString(), anyString()
I am new to RestAPI testing. I am trying to use Jsonschemavalidor. I added the jar file and all the dependencies. Still I get following error. Can anyone give solution to the problem.
Exception in thread "main" java.lang.NoSuchFieldError: USE_DEFAULTS
at com.fasterxml.jackson.annotation.JsonInclude$Value.<clinit>(JsonInclude.java:205)
at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:543)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:460)
at com.github.fge.jackson.JacksonUtils.newMapper(JacksonUtils.java:155)
at com.github.fge.jackson.JacksonUtils.<clinit>(JacksonUtils.java:55)
at com.github.fge.jackson.JsonNodeReader.<init>(JsonNodeReader.java:82)
at com.github.fge.jackson.JsonLoader.<clinit>(JsonLoader.java:50)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:164)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator$JsonSchemaValidatorFactory.create(JsonSchemaValidator.java:254)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema(JsonSchemaValidator.java:161)
at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath(JsonSchemaValidator.java:117)
at com.nasdaq.api.GenericLib.validateJsonSchema(GenericLib.java:441)
Did you add the latest version of jackson-annotations? The USE_DEFAULTS enum constant was added in 2.6:
I'm new to IntelliJ. I have some unit tests written in JUnit. For some reason, each tests runs twice. For the life of me, I can't figure out why. Can someone please provide some pointers in regards to why this might be happening. I would really like to get this down to a predicatable state.
Thanks
For example if you have a method annotated both with #Before and #Test annotations it will run twice:
#Test
#Before
public void testConnection()
{
// ...
}
I ran into an apparent (but only apparent) case of this as well. I was logging something at the beginning of the test and then the log message was showing up twice in the console, which made it look like the test was running twice.
The problem was that I had log4j misconfigured. My root logger was like this:
log4j.rootLogger=INFO, stdout
But my package-specific logger was like this:
log4j.logger.com.mycompany.myapp=TRACE, stdout
Log4j additivity resulted in the double-log.
The fix was simply to update my package-specific logger as follows:
log4j.logger.com.mycompany.myapp=TRACE
Hope this helps somebody out. This was aggravating.
I was trying to mock final class(AnyFinalClass.java) in junit using JDave in eclipse.
public void setUp() throws Exception {
Mockery mockery = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
AnyFinalClass any = mockery.mock(AnyFinalClass.class);
}
I am trying to use jdave-unfinalizer-1.1.jar as javaagent but didnt had any success. I tried multiple things but getting following exception
java.lang.IllegalArgumentException: Cannot subclass final class class AnyFinalClass
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
Can someone who has already tried jdave unfinalizer give me exact step how to make it work on eclipse.
I set following in eclipse.ini file but got the problem
-Xbootclasspath/a:lC:\WS\JunitTesting\jars\asm-3.0.jar
-javaagent:C:\WS\JunitTesting\jars\jdave-unfinalizer-1.1.jar
While running executing the junit, I gave vm argument as
javaagent:C:\WS\JunitTesting\jars\jdave-unfinalizer-1.1.jar
I am not sure what will be the code. jdave is not having the code and its site is pointing to some other site which is not working. Please correct my code or provide your same working code.
Any help is highly appreciated.
from Enhancer.java line 446:
if (TypeUtils.isFinal(sc.getModifiers()))
throw new IllegalArgumentException("Cannot subclass final class " + sc);
I have not worked with JDave but with another mocking frameworks and the only one that allows to mock a final class was powermock
Look also here
In order to get unfinalizer running you have to put -javaagent:path_to_unfinalizer/jdave-unfinalizer-1.1.jar in the VM arguments of the run configuration of the test.
I also had to include several dependencies of jdave-unfinalizer in the classpath of the project from which the tests ar being launched. These are, taken from the maven definitions of jdave:
jdave-core 1.1
cglib-nodep 2.1_3
objenesis 1.0
asm 3.0
asm-commons 3.0
asm-tree 3.0