Lecture 6 (Testing & Java Server Faces)
Lecture 6 (Testing & Java Server Faces)
Lecture 6 (Testing & Java Server Faces)
● Reaching anything near to complete code coverage, let alone full logical
coverage in an EE application - is quite a hassle because of all the required
mocking
When mocking simply doesn’t cut it
Two notable solutions exist
● CDI-Unit (bryncooke.github.io/cdi-unit)
● A complete shift in the way we write tests, allowing us to mimic or get the
behavior of the application server and the EE framework
● Supports CDI, JPA, EJB, Java Server Faces and most (if not all) parts of the
EE infrastructure
@Test
public void shouldDoSomethingSuccessfully() { … }
}
@EJB
private EntityDAO entityDao;
@Test
public void shouldReturnThisAndThatOnQuery() { … }
}
@FindByJQuery("input#name")
private WebElement name;
@RunAsClient @Test
public void shouldReturnThisAndThatOnQuery() { … }
}
#{myBean.myProperty}
#{myBean.myProperty + 10}
●
#{myBean.myProperty == 5}
#{myBean.invoice.customer["street"]} // value expressions
@PostConstruct
private init() {
name = “John Smith”;
}