Is there a Gatling2 REPL console? - scala

I would like to use a scala REPL console for Gatling to debug some code and evaluate it.
Is there any easy way to do that? Is there a fast way to do a syntax check on Gatling scripts?

If you're using SBT, you can always take advantage of SBT's console task to get Gatling in your classpath and and experiment with its APIs, but you won't be able to execute requests, etc... from the REPL.
The next best solution is to use Gatling's SBT plugin (https://github.com/gatling/gatling-sbt) : using it, you can quickly compile and run your simulations, even launch them on every successful compilation until the result suits you.

Related

VSCode metals, run specific ten in scalatest

is there a way in vscode with metals scala plugin, run specific test scenario ?
Like in IntelliJ ?
If you mean specific test clause in say a scalatest class, I'm pretty sure the answer is "no".
Workaround could be to add a launch configuration and pass args to just run the test you want with -z: https://scalameta.org/metals/docs/editors/vscode.html#via-a-launchjson-configuration
Or just ignore-tag the others.

Running simple Scala in Intellij

I'm trying to run a very simple hello world Scala program in IntelliJ IDEA on Mac without using the Scala console configuration. I have followed these steps to largely get started, but I didn't set up the debugger outlined there. There isn't a default run configuration enabled, but I can right-click on my source file and select "Scala Console," as we can see here:
Is there a way to select or edit my configurations to make it so I don't have to use the console? Below are the available configurations.
I simply want there to be a way to run my Scala code and see the generated output in the provided console, which Scala Console isn't doing. Thanks for your time.
Lab6 should be an object, not a class.
This will allow you to run it as a main method

Is there any way to fork the SBT console into a new JVM?

For all the reasons listed here:
http://www.scala-sbt.org/0.13/docs/Running-Project-Code.html
it's sometimes necessary to run your Scala code in a separate JVM from the one in which SBT is running. That's also true of the REPL, which you access from the console or test:console commands.
Unfortunately, it doesn't appear that SBT supports running the console in its own JVM (and I'm posting this question here, as requested in the message):
https://groups.google.com/forum/#!topic/simple-build-tool/W0q62PfSIMo
Can someone confirm that this isn't possible and suggest a possible workaround? I'm trying to play with a ScalaFX app in the console, and I have to quit SBT completely each time I run it. It'd be nice to just have to quit the console and keep SBT running.

how to auto-reload changed scala classes into SBT REPL

I am new to Scala and to using emacs + ensime + sbt setup for my Scala development.
This setup is quite nice and light, but there is one thing which drives me nuts - inability to auto-compile / reload changes into Scala console started from sbt.
I use REPL a lot and would like to be able to start REPL from sbt with console command and test my changes to scala classes from REPL without having to close it and reload every time I make a change.
I come from Erlang environment and this way of development is easy with Erlang but seems to be difficult with SBT. I have the JRebel plug-in installed but it doesn't seem to be working for the situation I described.
Has anybody been able to make something similar work and would be willing to share the configuration steps?
Much appreciated in advance.
There are two things possible in sbt:
Causing automatic recompilation of the project sources triggered by a file change by prefixing a command with ~ (tilde). The console, or console-quick, or console-project commands can be prefixed, too, but you have to exit REPL to make the recompilation happen (just hit Ctrl+D and wait.)
Causing automatic execution of REPL commands just after firing the console. They can be defined as properties (e.g. in build.sbt):
initialCommands in console := """
import some.library._
def someFun = println("Hello")
"""
It's not necessary to define the property separately in consoleQuick because it defaults to the one defined in console, but if you would like to use the console-project command you have to define it separately.
On a final note: remember to leave empty line between every property in an *.sbt file. They're necessary to parse the properties correctly. In the example above there are no blank lines in between so it means that everything goes into the initialCommands property (and that's what we want.)

Improving productivity with Scala test cycle

It would be great to improve test driven development productivity by automatically firing of tests whenever there is a code change.
This is what I'm hoping for.
Whenever a Scala file is saved, SBT (or a shell script) should execute the ScalaTest or Specs2 specifications.
If the tests complete, the system should play a sound indicating success or failure
I'm using Scala IDE to do development and SBT to run my test specs at the moment, so just autimating the steps above would save a person from switching to the console, running the test specs and waiting for the result.
Any ideas automatically firing of the tests and playing a 'succeed' or 'fail' sound would be great.
Why not create a custom SBT task that depends on the test task. You could add the code for playing the sound to your build definition.
See here how to run a custom task after another task.
To automatically re-run tests, simply prefix the newly define task with a ~ in the SBT shell before running it.