Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: junit - maven
Hi,
is there any place where can I check simple project with liferay 7 + junit + @inject ?
I'm trying to do simple test with documentation https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/injecting-service-components-into-tests
but still strange problems.
For example - what scope of kernel dependency should I use? Provided?
In such cache I'm receiving: Caused by: java.lang.ClassNotFoundException: com.liferay.petra.concurrent.ConcurrentReferenceKeyHashMap
in short I have:
MVC project
1 @Component with small logic -> I'd like to add test for some methods.
I've added dependencies:
and in Test class I have:
It is not working - because kernel classes are not accessible.
Does anyone have working example how to implement junit tests?
is there any place where can I check simple project with liferay 7 + junit + @inject ?
I'm trying to do simple test with documentation https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/injecting-service-components-into-tests
but still strange problems.
For example - what scope of kernel dependency should I use? Provided?
In such cache I'm receiving: Caused by: java.lang.ClassNotFoundException: com.liferay.petra.concurrent.ConcurrentReferenceKeyHashMap
in short I have:
MVC project
1 @Component with small logic -> I'd like to add test for some methods.
I've added dependencies:
<groupid>com.liferay.portal</groupid>
<artifactid>com.liferay.portal.test</artifactid>
<version>4.0.1</version>
<scope>test</scope>
<dependency>
<groupid>com.liferay.portal</groupid>
<artifactid>com.liferay.portal.test.integration</artifactid>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<scope>test</scope>
</dependency>
and in Test class I have:
@ClassRule
@Rule
public static final AggregateTestRule aggregateTestRule = new LiferayIntegrationTestRule();
@Inject
private MyService myService;
It is not working - because kernel classes are not accessible.
Does anyone have working example how to implement junit tests?
I am also stuck same way. Do you resolved this?
Anybody could fix this?
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™