At AtlasCamp 2018, Jon Mort and Mark Gibson from Adaptavist gave a presentation about how they brought Arquillian into the Atlassian SDK.
In this talk, Jörg Brandstätt from Resolution will help you to put their learnings into practice and take your tests to the next level. He will also share how Resolution is using this approach to test some of the Top 30 Server & Data Center apps.
The session covers how you can run your test code on remote Server and Data Center instances with different databases ad-hoc from within your IDE and during the build process, and provide detailed information about how to set up Maven to execute your tests within your Bitbucket build pipelines.
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Integration Testing on Steroids: Run Your Tests on the Real Things
1. JÖRG BRANDSTÄTT | SENIOR DEVELOPER | RESOLUTION | @BLAFASELDINGS
Integration Testing on Steroids
Run Your Tests on the Real Things
2. Thanks to
Mark Gibson & Jon Mort
Check out their talk at
AtlasCamp 2018:
Rule your Tests with
Arquillian
https://youtu.be/_s_kL6V8pUI
This is
based on
Adaptavist’s
Arquillian-
adaption
3. We are going to talk about
test P2 Plugins for Server
only.
This is a cloud free zone.
MARK GIBSON, JON MORT
18. Databases
Components can
behave fine on H2
but fail or become
slow on other
databases
Prepared
environment
Tests can require
specific configuration
in the instance.
Integration Tests should run on real instances
19. Databases
Components can
behave fine on H2
but fail or become
slow on other
databases
Prepared
environment
Tests can require
specific configuration
in the instance.
Datacenter
Running component
tests on datacenter
allows spotting
issues early.
Integration Tests should run on real instances
20. Databases
Components can
behave fine on H2
but fail or become
slow on other
databases
Prepared
environment
Tests can require
specific configuration
in the instance.
Datacenter
Running component
tests on datacenter
allows spotting
issues early.
Survives
atlas-clean
Cleaning the project
does not wipe the
test-instance
Integration Tests should run on real instances
35. Arquillian -
Test
Concepts
Test Code
arquillian.xml
Junit + Dependency Injection
Like unit tests, but with dependency injection.
One test-plugin per test class
For each test-class, a plugin is automatically built
during execution
36. Arquillian -
Test
Concepts
Test Code
arquillian.xml
Junit + Dependency Injection
Like unit tests, but with dependency injection.
One test-plugin per test class
For each test-class, a plugin is automatically built
during execution
Deployed and executed remotely
The test plugin is deployed to the remote instance and
executed there
37. @RunWith(Arquillian.class)
public class LogEntryRepositoryTest {
@Inject @ComponentImport
private LogEntryRepository logEntryRepository;
@Test
public void runTest() {
...
Assert.assertEquals(3,logEntryRepository.fetch(
start,System.currentTimeMillis()).size());
Assert.assertEquals(2,logEntryRepository.fetch(
after0,System.currentTimeMillis()).size());
}
}
Arquillian-
Test
Concepts
Test Code
arquillian.xml
45. The Maven
Build
Lifecycle
AMPS-Plugin
Phases
Test-phases
Adapted
Maven builds consist of phases
The build lifecycle is a list of phases which are executed
sequentially.
Maven-plugins provide goals
Everything in Maven is done by execution a plugin's goal.
Goals are bound to phases
Executing a phase means executing the bound goals.
Concepts
50. No local instance
We don’t want to spin up local instances
Install our App
We need our app installed
Execute our Tests
We want to run our tests on the remote instance.
What we
want to do
51. No local instance
We don’t want to spin up local instances
Install our App
We need our app installed
What we
want to do
Execute our Tests
We want to run our tests on the remote instance.
52. No local instance
We don’t want to spin up local instances
Install our App
We need our app installed
Execute our Tests
We want to run our tests on the remote instance.
What we
want to do
70. @Deployment
public static Archive<? extends Assignable> deployTests() {
Properties envProperties = new Properties();
envProperties.putAll(System.getenv());
try(FileWriter wr =
new FileWriter(
"target/test-classes/env.properties",false)) {
envProperties.store(wr,null);
} catch (IOException e) {
throw new RuntimeException(e);
}
return ShrinkWrap.create(
JavaArchive.class, "tests.jar")
.addAsResource("env.properties");
}
Transport
your
Bitbucket Env
Store it
Use it
71. private final Properties envProp;
public ITest() {
envProp = new Properties();
try {
envProp.load(ITest.class
.getResourceAsStream("/env.properties"));
} catch (IOException e) {
throw new RuntimeException(
"Loading env.properties failed",e);
}
}
@Test
public void runTest() {
...
String value = envProp.get("env_key");
}
Store it
Use it
Transport
your
Bitbucket Env