


Hi All,
i have written a multifield in if else statement now,
I need to write JUnits for that Method (getMltifeildlist()) help me with the Testing code for this method
Solved! Go to Solution.
Views
Replies
Sign in to like this content
Total Likes
Hi,
I have an example here but the implementation may be different for multifield
Test
@HariDo you can write this as below
@BeforeEach
void setUp() throws Exception {
List<LinkComponentImpl> linkcomponentimpl = new ArrayList<>();
linkComponentimplClass = new LinkComponentImpl();
}
/**
* Test.
*/
@Test
void test() {
Assert.assertNotNull(linkComponentimplClass.getMultifieldlist());
}
Use this code for Example
Main Class: @Override public List<String> getBooks() { if (books != null) { return new ArrayList<String>(books); } else { return Collections.emptyList(); } } Test Class: private final AemContext aemContext=new AemContext(); private Author author; @Test void getBooks() { aemContext.currentResource("/component/author"); author=aemContext.request().adaptTo(Author.class); assertEquals(4,author.getBooks().size()); assertEquals("JAVA",author.getBooks().get(0)); assertEquals("DS",author.getBooks().get(2)); }
Hi,
I have an example here but the implementation may be different for multifield
Test