wooga / atlas-paket

Paket plugin for gradle
https://wooga.github.io/atlas-paket/
Apache License 2.0
0 stars 2 forks source link

Refactor integration spec for paket unity change specs #47

Closed Larusso closed 5 years ago

Larusso commented 5 years ago

Description

This patch moves some boilerplate setup code into custom spock extensions. This patch adds two extensions that provide a clean interface for testing paket and paket unity project integrations:

@PaketDependency

Is a resource extension which setups a paket project. It will create a paket.dependendies along with a paket.lock file and stub cs files in packages directory. This extensions should be updated for future use in other tests (don't create a lock file, specify sources, etc).

@ExtensionAnnotation(PaketDependencySetupExtension)
@interface PaketDependency {
    String[] projectDependencies() default []
}
class ASpec extends IntegrationSpec {
    @PaketDependency(projectDependencies = ["D1", "D2", "D3"])
    PaketDependencySetup paketSetup

The annotated field will turn into a an Object of PaketDependencySetup It is possible to override and regenerate the dependencies during test runtime.

interface PaketDependencySetup {
    File getPaketDependencies()
    File getPaketLock()

    List<String> getProjectDependencies()

    File createDependencies()
    File createDependencies(List<String> dependencies)
}

@PaketUnity

The paket unity extension creates a mock setup for unity. Each field annotated with @PaketUnity will generate a mock unity project.

@ExtensionAnnotation(PaketUnitySetupExtension)
@interface PaketUnity {
    String projectName() default ""
    String[] projectReferences() default []
}
class ASpec extends IntegrationSpec {
    @PaketUnity(projectReferences = ["D1", "D2", "D3"])
    PaketUnitySetup unityProject1

The annotated field will turn into a an Object of PaketUnitySetup It is possible to override and regenerate the references during test runtime.

interface PaketUnitySetup {
    File getProjectReferencesFile()
    File getInstallDirectory()
    File getUnityProjectDir()
    String getName()

    List<String> getProjectReferences()

    File createOrUpdateReferenceFile()
    File createOrUpdateReferenceFile(List<String> projectReferences)
}

Changes

ADD @PaketDependency spock test extension ADD @PaketUnity spock test extension IMPROVE integration specs