RE: junit - maven

thumbnail
Bartlomiej Knabel, modified 7 Years ago. Junior Member Posts: 76 Join Date: 1/30/11 Recent Posts
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:

	<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?
Sana Yafai, modified 6 Years ago. New Member Posts: 3 Join Date: 1/16/19 Recent Posts
I  am also stuck same way. Do you resolved this?
thumbnail
Joaquin Cabal, modified 6 Years ago. Regular Member Posts: 106 Join Date: 9/7/09 Recent Posts
Anybody could fix this?