Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Unit test(using osgi-mock.junit5) to read osgi config fails to build

Avatar

Avatar
Level 1
rachnamehta
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
rachnamehta
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile
rachnamehta
Level 1

17-02-2021

Unit test fails with message

org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi SCR metadata found for class

 

 I have written a unit test using OSGi-mock-junit5 but when I try to build the project(mvn clean install), I get the failure message "org.apache.sling.testing.mock.osgi.NoScrMetadataException: No OSGi SCR metadata found for class"

 

I found similar post  https://cqdump.wordpress.com/2019/01/14/writing-unit-tests-for-aem-part-2-maven-setup/ & followed the steps to fix it but it's still the same issue.

 

anyone has got any idea?

Thanks in advance!

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile
davidjgonzalezzzz
Level 5

17-02-2021

After following the POM updates in the linked blog update, try the following maven commands:

 

$ mvn clean package -DskipTests
$ mvn test

 IIRC I would occasionally run into this issue if the OSGi SCR metadata XML files weren't generated when the tests ran; doing the `mvn clean package` would generate this for me and then allow my tests to run (you could try dialing it back to `mvn clean compile` or other phases/goals)