2016-08-01 4 views
6

Spark 통합 테스트를 위해 Maven에서 scalatestspark-testing-base을 사용하려고합니다. Spark 작업은 CSV 파일을 읽고 결과의 유효성을 검사 한 다음 데이터를 데이터베이스에 삽입합니다. 나는 알려진 형식의 파일을 넣고 실패한 지 확인하는 방법으로 검증을 테스트하려고합니다. 이 특정 테스트는 유효성 검사가 통과하는지 확인합니다. 불행히도, scalatest는 내 테스트를 찾을 수 없습니다.Scalatest Maven Plugin "테스트를 실행하지 않았습니다"

관련 치어 플러그인 :

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <skipTests>true</skipTests> 
      </configuration> 
     </plugin> 
     <!-- enable scalatest --> 
     <plugin> 
      <groupId>org.scalatest</groupId> 
      <artifactId>scalatest-maven-plugin</artifactId> 
      <version>1.0</version> 
      <configuration> 
       <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> 
       <wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites> 
      </configuration> 
      <executions> 
       <execution> 
        <id>test</id> 
        <goals> 
         <goal>test</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

그리고 여기 테스트 클래스의 :

class ProficiencySchemaITest extends FlatSpec with Matchers with SharedSparkContext with BeforeAndAfter { 
    private var schemaStrategy: SchemaStrategy = _ 
    private var dataReader: DataFrameReader = _ 

    before { 
     val sqlContext = new SQLContext(sc) 
     import sqlContext._ 
     import sqlContext.implicits._ 

     val dataInReader = sqlContext.read.format("com.databricks.spark.csv") 
              .option("header", "true") 
              .option("nullValue", "") 
     schemaStrategy = SchemaStrategyChooser("dim_state_test_proficiency") 
     dataReader = schemaStrategy.applySchema(dataInReader) 
    } 

    "Proficiency Validation" should "pass with the CSV file proficiency-valid.csv" in { 
     val dataIn = dataReader.load("src/test/resources/proficiency-valid.csv") 

     val valid: Try[DataFrame] = Try(schemaStrategy.validateCsv(dataIn)) 
     valid match { 
      case Success(v) =>() 
      case Failure(e) => fail("Validation failed on what should have been a clean file: ", e) 
     } 
    } 
} 

내가 mvn test를 실행하면 모든 테스트 및 출력이 메시지를 찾을 수 없습니다 :

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ load-csv-into-db --- 
[36mDiscovery starting.[0m 
[36mDiscovery completed in 54 milliseconds.[0m 
[36mRun starting. Expected test count is: 0[0m 
[32mDiscoverySuite:[0m 
[36mRun completed in 133 milliseconds.[0m 
[36mTotal number of tests run: 0[0m 
[36mSuites: completed 1, aborted 0[0m 
[36mTests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0[0m 
[33mNo tests were executed.[0m 

업데이트
01 사용하여 23,516,:

<suites>com.cainc.data.etl.schema.proficiency.ProficiencySchemaITest</suites> 

대신 :

<wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites> 

나는 하나의 테스트를 실행하는 것을 얻을 수 있습니다. 분명히 이상적인 것은 아닙니다. 와일드 카드가있을 수 있습니다. 나는 GitHub에서 티켓을 열고 무슨 일이 일어날지를 볼 것입니다.

+0

'ProficiencySchemaITest'는 어디에 있습니까? – hasumedic

+0

src/test/scala/com/cainc/data/etl/schema/proficiency/ProficiencySchemaITest.scala. src/main/scala \t \t src/test/scala Azuaron

+0

또한'''target /'''에서 '''.class''' 파일이 생성되었습니다. – Azuaron

답변

2

이것은 아마도 프로젝트 경로에 공백 문자가 있기 때문일 수 있습니다. 프로젝트 경로에서 공간을 제거하면 테스트를 성공적으로 검색 할 수 있습니다. 도움이 되길 바랍니다.

+0

전체 경로 : C : \ dev \ projects \ nintendo \ spark-data-load \ src \ main \ blah \ blah \ blah – Azuaron

+0

프로젝트 경로의 공백 문제는이 PR : https : // github에서 수정해야합니다. com/scalatest/scalatest-maven-plugin/pull/37 – cstroe

0

전 이적 종속성으로 junit을 제외 시키십시오. 나를 위해 일합니다. 아래의 예에서 스칼라와 스파크 버전은 내 환경에만 적용됩니다.

<dependency> 
     <groupId>com.holdenkarau</groupId> 
     <artifactId>spark-testing-base_2.10</artifactId> 
     <version>1.5.0_0.6.0</version> 
     <scope>test</scope> 
     <exclusions> 
      <!-- junit is not compatible with scalatest --> 
      <exclusion> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </exclusion> 
     </exclusion> 
    </dependency> 
관련 문제