| 1 |
/* |
| 2 |
* Copyright 2015-2024 the original author or authors. |
| 3 |
* |
| 4 |
* All rights reserved. This program and the accompanying materials are |
| 5 |
* made available under the terms of the Eclipse Public License v2.0 which |
| 6 |
* accompanies this distribution and is available at |
| 7 |
* |
| 8 |
* https://www.eclipse.org/legal/epl-v20.html |
| 9 |
*/ |
| 10 |
|
| 11 |
package org.junit.platform.fakes; |
| 12 |
|
| 13 |
import org.junit.platform.engine.EngineDiscoveryRequest; |
| 14 |
import org.junit.platform.engine.ExecutionRequest; |
| 15 |
import org.junit.platform.engine.TestDescriptor; |
| 16 |
import org.junit.platform.engine.TestEngine; |
| 17 |
import org.junit.platform.engine.UniqueId; |
| 18 |
|
| 19 |
/** |
| 20 |
* @since 1.4 |
| 21 |
*/ |
| 22 |
public class TestEngineSpy implements TestEngine { |
| 23 |
|
| 24 |
private final String id; |
| 25 |
|
| 26 |
public ExecutionRequest requestForExecution; |
| 27 |
|
| 28 |
public TestEngineSpy() { |
| 29 |
this(TestEngineSpy.class.getSimpleName()); |
| 30 |
} |
| 31 |
|
| 32 |
public TestEngineSpy(String id) { |
| 33 |
this.id = id; |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
public String getId() { |
| 38 |
return id; |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) { |
| 43 |
var engineUniqueId = UniqueId.forEngine(id); |
| 44 |
var engineDescriptor = new TestDescriptorStub(engineUniqueId, id); |
| 45 |
var testDescriptor = new TestDescriptorStub(engineUniqueId.append("test", "test"), "test"); |
| 46 |
engineDescriptor.addChild(testDescriptor); |
| 47 |
return engineDescriptor; |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public void execute(ExecutionRequest request) { |
| 52 |
this.requestForExecution = request; |
| 53 |
} |
| 54 |
|
| 55 |
} |