logo
down
shadow

SBT cannot resolve class declared in src/main/scala in a src/test/scala test class


SBT cannot resolve class declared in src/main/scala in a src/test/scala test class

By : user2951940
Date : November 18 2020, 03:49 PM
hop of those help? You forgot the new keyword. Without it, the compiler looks for the companion object named CSVStream, not the class. Since there is none, it complains. Add new and it'll work.
code :


Share : facebook icon twitter icon
Why is my Scala class not visible to its matching test class?

Why is my Scala class not visible to its matching test class?


By : user3685356
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am starting out in Scala with SBT, making a Hello World program. , The problem is this expression:
code :
new Hello.sayHelloTo("Scala")
(new Hello).sayHelloTo("Scala")
Scala Error: Could not find or load main class in both Scala IDE and Eclipse

Scala Error: Could not find or load main class in both Scala IDE and Eclipse


By : Jerry Walton-Pratche
Date : March 29 2020, 07:55 AM
To fix this issue Here is my problem, I know there are lots of answers for similar questions, however none of them worked after I tried. I'm using both Scala IDE 4.6 and eclipse Oxygen to run the code and all failed on this error. , I think this should be your folder structure
code :
Scala0
└── src
    └── main
        └── scala
            └── com.ks.sparkscala
                └── FriendsByAge
scala - unit test - How to mock a class method inside a class

scala - unit test - How to mock a class method inside a class


By : Suresh atta
Date : March 29 2020, 07:55 AM
seems to work fine The problem with your last code snippet is that val b = mock[B] is a different variable from the b field of your class. You can fix this by modifying the class to take b as an optional argument:
code :
class A(b: B = new B) {
  def doSomething(): Unit = {
    b.someMethod()
  }
}
val b = mock[B]
when(b.someMethod()).thenReturn(xx)
val classToTest = new A(b)
classToTest.doSomething()
class A private[myPackage](b: B) {
  def this() = this(new B)  // The public constructor doesn't expose b.

  def doSomething(): Unit = {
    b.someMethod()
  }
}
How to make acces to src.test package from main class in Java or how to run test class from main class?

How to make acces to src.test package from main class in Java or how to run test class from main class?


By : Nezde6nij
Date : March 29 2020, 07:55 AM
I hope this helps . classes in test folders are not included in application after build, so if you want to run PageTest from your main classes, make sure your PageTest class is not in test folder.
Sbt run tests from src/main/scala instead of src/test/scala?

Sbt run tests from src/main/scala instead of src/test/scala?


By : James Sturms
Date : March 29 2020, 07:55 AM
this one helps. Say I have a scalatest class in main/scala, like , Put ScalaTest on Compile classpath in build.sbt like so
code :
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0"
object MainTests extends App {
  org.scalatest.run(new ExampleSpec)
}
package example

import org.scalatest.matchers.should.Matchers
import org.scalatest.flatspec.AnyFlatSpec
import collection.mutable.Stack
import org.scalatest._

class ExampleSpec extends AnyFlatSpec with Matchers {
  "A Stack" should "pop values in last-in-first-out order" in {
    val stack = new Stack[Int]
    stack.push(1)
    stack.push(2)
    stack.pop() should be (2)
    stack.pop() should be (1)
  }
}

object MainTests extends App {
  org.scalatest.run(new ExampleSpec)
}
class ExampleASpec extends FlatSpec with Matchers {
  "ExampleA" should "run" in { succeed }
}
class ExampleBSpec extends FlatSpec with Matchers {
  "ExampleB" should "run" in { succeed }
}

class ExampleSuite extends Suites(
  new ExampleASpec,
  new ExampleBSpec,
)

object MainTests extends App {
  (new ExampleSuite).execute()
}
Related Posts Related Posts :
  • Recommended Scala io library
  • Thread-safely transforming a value in a mutable map
  • Why does chaining match expressions does not compile?
  • Ebean not persisting foreign keys
  • Difference between def m(p: T forSome {type T} and def m1(p:Any), is there any ? Explanation needed based on Scala Langu
  • macro does not find out enclosing vals
  • Spark : how to run spark file from spark shell
  • Flattening a list of lists to a set with exceptions in scala
  • flatMap implementation in Scala
  • Confused about a few lines code in a scala official document page
  • How to input parameters when running bash command with Scala
  • Location header is lost if max-redirects > 1
  • Controller Spec is using FakeApplication, but can't load test configuration
  • Scala code analyzer targets case variable names that are identical to the outer matched varables - "suspicous shado
  • Why does authorize directive execute after the code it's supposed to protect?
  • Scala. Checking if a Type is Comparable
  • Does having a private constructor on a value class negate the benefits of a value class?
  • How to transform submitted json in Play 2.0?
  • Scala warning match may not be exhaustive
  • Pure not a member of objective Promise in PlayFramework
  • How to unmarshal POST params and JSON body in a single route?
  • Spark:How to use join method?
  • is client thread-safe in Twitter Finagle
  • Why is the method accepts only one argument?
  • Scala Play 2.3 Working with gCloud Storage - any libs to go async?
  • spray.io strange get/delete/detach directives behavior
  • Scala typeclass without function argument
  • Configuring actor behavior using typesafe Config and HOCON
  • Scalatra: Migrating Jersey Filters to Scalatra
  • Compilation error when using Scaldi
  • Scalac hanging in phase typer
  • how to have different source code when cross-compiling Scala with sbt? (changes in MurmurHash)
  • How to set different scalacOptions per Scala version when cross-compiling using Build.scala?
  • Possible Bug in JDBC?
  • Is there a Scala compiler flag to warn when tail recursion is applied without annotation?
  • scala case class put methods in companion object?
  • multiproject sbt doesn't generate file structure
  • Scala "multilevel" abstract class / abstract objects replacement
  • Scala, getting the type parameters of a KList as an HList
  • Why does Play refuse form reporting "Cannot resolve method apply with such signature: Missing arguments"?
  • How to split string with trailing empty strings in result?
  • Scala group by list of list and subtracts grouped values
  • Scala - Creating a function to produce Unary string or integer values
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org