Upload
efratao
View
257
Download
1
Embed Size (px)
Citation preview
2
Introduction & key factors
• Automation developers can change the tested application itself for the automation needs
• Programming language is not a barrier (JS in our example) -knowledge and deep understating of the tested application code
• Don’t wait for developers to do it for you – DIY
3
BI Events Testing
• BI – Business Intelligence
• Monitoring behavior of applications
• Statistical analysis
4
How to verify? The Wrong Way
• Manually with Charles?
• Automatically Monitor network traffic and analyze it on the fly?
• Query the server to check if event was sent as expected?
5
How to verify? The Right Way
• Change the tested application (Wix Editor) code and “implement” bi event method for automation needs
• Provide clear descriptive java framework to verify bi events (based on the js implementation)
• Create events scheme automatically (not hard coded) – offline process
6
How to verify?
if (isInTestingMode()) { editor.biEventHandler = onBiEvent;
}
• Override client’s JS method responsible for sending BI events
7
How to verify?
function onBiEvent(e) { window.bi.add(e);
}
• Override client’s JS method responsible for sending BI events
8
How to verify?
• Override client’s JS method responsible for sending BI events• Helper class: bi.js
... return {
getAll: getAll, getById: getById, getSize: getSize, add: add, clear: clear
};
9
How to verify?
• Java Framework• Helper class: BiEvents.java
• Implementation: execute script (window.bi)
interface BiEvents { List<BiEvent> getAll(); Optional<BiEvent> getEventById(int id); int getSize(); void clear();
}
10
How to verify?
• Java Framework• Helper class: BiVerifier.java
BiVerifier eventWasSent(int eventId) { // Verify: biEvents.getEventById(eventId).isPresent()...
}
11
How to verify?
• Java Framework• We want:
@ExpectBiEvent(id = {17, 5000}) @Testpublic void testSomething() {
… }
12
How to verify?
• Java Framework• New annotation: ExpectBiEvent
@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.METHOD) @interface ExpectBiEvent {
int[] eventIds();
}
14
How to verify?
• Java Framework• Reminder - Test Observer
interface TestObserver { … default void ending() { } …
}
15
How to verify?
• Java Framework• Helper class: BiEventObserver.java
private Optional<T extends Annotation> getAnnotation(Class<T> type)
@Overridepublic void ending() {
getAnnotation(ExpectBiEvent.class) .map(ExpectBiEvent::eventIds) .map(Ints::asList) .ifPresent(ids -> ids.forEach(biVerifier::eventWasSent));
}
16
How to verify?
• Event Scheme Creation• Generate event schemes automatically
• Save generated schemes as resource files
• Validate as part of the verification process
17
How to verify?
• Java Framework• Helper class: BiVerifier.java
BiVerifier eventWasSent(int eventId) {
Optional<BiEvent> biEvent = biEvents.getEventById(eventId); // Verify: biEvent.isPresent()biEvent.ifPresent(this::schemeIsValid);
…
}
18
How to verify?
• Java Framework• Helper class: BiVerifier.java
BiVerifier schemeIsValid(BiEvent biEvent) { // expectedScheme = loadBiEventScheme(biEvent.id());// actualScheme = biEvent.scheme();// Verify: actual vs expected
…
}